我要解决的依赖关系依赖于变化的数据。您如何强制 Angular 再次解决依赖关系?
$routeProvider.
when('/blah', {
templateUrl: '/static/views/myView.html',
controller: 'myCtrl',
resolve: {
theData: function(myFactory) {
return myFactory.promise;
}
}
}).
即,每次执行此 when
block 时,我都想重新解决依赖关系。
这是微不足道的吗?
最佳答案
每次路线更改时都会重新检查解析 block 。在你的情况下,你需要每次都返回新的 promise ,而不是你目前的做法。看起来您总是缓存并返回相同的 promise 对象。
resolve: {
theData: function(myFactory) {
return myFactory.getSomething();
}
}
让 myFactory.getSomething
在每次调用中返回新的 promise 。
关于javascript - Angular : force resolve again,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27478813/