【发布时间】:2014-10-07 09:18:29
【问题描述】:
我的问题有两个:
1 - 我有一个父状态和几个使用 ui.router 的子状态,所有状态都需要一个对象(存储在 mongodb 中),但它会被所有状态更新。在这种情况下,使用父状态的解析选项来填充对象是否有意义?
2 - 如果这是执行此操作的正确方法,我如何将“引用”(由 ui.router 创建的模拟服务注入器)从每个状态更新到该对象。
为了帮助解释他是这个想法的一个例子(省略了很多代码)
.state('parent',resolve:{objectX:return x.promise;},...);
.controller('childstateCtrl',$scope,objectX){
$scope.data.objectX = objectX;
$scope.someEvent =function(){
// something updates objectX on the scope
}
}
.controller('otherChildCtrl',$scope,objectX){
// how to get the updated objectX?
}
提前致谢
【问题讨论】:
标签: angularjs angular-ui-router