resolve in ui-router

来源:互联网 发布:以是知公子恨之复返也 编辑:程序博客网 时间:2024/05/16 00:29

* Forcing resolution before the controller executes *

.state('state2', {    url: '/state2',    templateUrl: 'page2.html',    controller: 'Page2Ctrl',    resolve: {        gistsData: function(Gists) {            var GistsData = Gists.query();            return GistsData.$promise;        }    }});myApp.controller('Page2Ctrl', ['$scope', 'gistsData', function($scope, gistsData) {    $scope.gists = gistsData;}]);

With the support of $promise to force resolution before the controller executes.

http://www.jvandemo.com/how-to-resolve-angularjs-resources-with-ui-router/



Centrally. Hierarchically. Per state. Using promises. Like a pro.
http://www.jvandemo.com/how-to-resolve-application-wide-resources-centrally-in-angularjs-with-ui-router/



Use AngularUI Router and nested resolves to move data-loading logic out of the controller to avoid code duplication and coupling between controllers.
https://medium.com/opinionated-angularjs/advanced-routing-and-resolves-a2fcbf874a1c#.5hivtypb6



Resolve promises in Angular routes

AngularJS: Pitfalls using ui-router’s resolve

0 0
原创粉丝点击