arh*_*ins 11 javascript angularjs
我要解决的依赖项依赖于更改的数据.你如何强制角度再次解决依赖关系?
$routeProvider.
when('/blah', {
templateUrl: '/static/views/myView.html',
controller: 'myCtrl',
resolve: {
theData: function(myFactory) {
return myFactory.promise;
}
}
}).
Run Code Online (Sandbox Code Playgroud)
也就是说,每次when执行此块时,我都想重新解决依赖关系.
这是微不足道的,还是没有那么多?
每次路线更改时都会重新检查解决块。在你的情况下,你需要每次返回新的承诺,而不是你当前的做法。看起来您缓存并始终返回相同的承诺对象。
resolve: {
theData: function(myFactory) {
return myFactory.getSomething();
}
}
Run Code Online (Sandbox Code Playgroud)
myFactory.getSomething在每次调用中返回新的承诺。
| 归档时间: |
|
| 查看次数: |
667 次 |
| 最近记录: |