我想要做的是使用ui-router resolution angular install-bar。
如何运行Resolve中提供的代码?
resolve: {
return {
loadedData: function($rootScope, $q) {
var deferred = $q.defer();
$rootScope.$on('cfpLoadingBar:completed', function() {
console.log("complete");
deferred.resolve();
});
return deferred.promise;
}
};
}
作为一个例子;
greeting: function($q, $timeout){
var deferred = $q.defer();
$timeout(function() {
deferred.resolve('Hello!');
}, 1000);
return deferred.promise;
}
而不是
我想运行此代码,它每次超时都有效。 Rootscope.on仅在加载页面时起作用。
greeting: function($q, $rootScope){
var deferred = $q.defer();
$rootScope.$on('cfpLoadingBar:completed', function(){
deferred.resolve('Hello!');
});
return deferred.promise;
}