javascript - How to delay angular bootstrap until after a service call -


i'm beginner on angular. i've got need make multiple webservice calls , bootstrap model. i've tried placing following code inside function executed after webservices have run.

        var myapp = angular.module('myapp', [])         myapp.controller('ctrl', ['$scope', function ($scope) {             $scope.obj = model         }]);          angular.element(document).ready(function () {             angular.bootstrap(document, ['myapp']);         }); 

but receive following exception.

[$injector:modulerr] failed instantiate module myapp due to: [$injector:nomod] module 'myapp' not available! either misspelled module name or forgot load it. if registering module ensure specify dependencies second argument.

my code still works, want rid of exception , more importantly learn how angular code should structured when bootstrapping delayed.

i don't know if help, i'm including in case.

    <div ng-app ng-controller="ctrl">        <div ng-repeat="o in obj track $index">        </div>        <input id="model" type="hidden" value="{{obj}}" />     </div> 

i found earlier attempts working added following html tag.

ng-app="myapp"  

when removed error went away. believe how perform automatic bootstrapping, since needed delayed bootstrapping causing issues. here link more information on directive

ng-app directive

if more familiar angular verify understanding appreciate it. thank arun fiddle.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -