angularjs - Load the route Template/Controller after all the $http async calls have completed -


currently, have index.html below contents:

<div ng-controller="maincntl">       <div ng-view></div> </div> 

ng-view loads either "template1.html" or "template2.html" based on route url. "template1" controlled "controller1" , "template2" controlled "controller2".

what want do: load url mapped content(using $routeprovider) after async calls inside maincontroller have completed.

any suggestion highly appreciated.

angularjs routes have property purpose, resolve property:

window.angular.module('app',[])   .config(['$routeprovider', function($routeprovider) {     $routeprovider       .when('/', {         templateurl: 'afterdoingsomething.html',         controller: 'appctrl',         resolve: {           // function returns promise         }       })       .otherwise({         redirectto: '/'       });   }]) 

this way, after returned promise resolved view load.

there no sense in trying explain this, when egghead explains so, well:

remember $http or $resource call return these promisses, don't have work them directly (return $http(...) works - or can combine many $http calls 1 promise)


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

c++ - End of file on pipe magic during open -