我很难理解如何通过 angularjs中的ng-repeat 的表达来跟踪轨迹.文档很稀缺:http://docs.angularjs.org/api/ng/directive/ngRepeat
你能解释这两个代码片段在数据绑定和其他相关方面的区别吗?
有: track by $index
<!--names is an array-->
<div ng-repeat="(key, value) in names track by $index">
<input ng-model="value[key]">
</div>
Run Code Online (Sandbox Code Playgroud)
没有(相同的输出)
<!--names is an array-->
<div ng-repeat="(key, value) in names">
<input ng-model="value[key]">
</div>
Run Code Online (Sandbox Code Playgroud) 更新:这应该可以在angular-ui-router中使用1.0.0alpha0.请参阅发行说明https://github.com/angular-ui/ui-router/releases/tag/1.0.0alpha0和问题https://github.com/angular-ui/ui-router/issues/1018 I创建.
在处理解决方案时,我想访问应用程序导航到使用角度ui-router的状态名称和其他属性.
原因是:我想在允许应用程序输入该页面之前异步加载一些用户数据(包括其访问权限).
目前这是不可能的,因为将$ state注入解决点指向您正在导航的状态,而不是您要导航到的状态.
我知道我可以:
我还在ui-router github上创建了一个问题(如果你有兴趣,请点击+1):https: //github.com/angular-ui/ui-router/issues/1018
到目前为止,这是我的代码.任何帮助赞赏!
.config(function($stateProvider) {
$stateProvider.state('somePage', {
// ..
resolve: {
userData: function($stateParams, $state, Settings) {
return Settings.getUserData() // load user data asynchronously
.then(function (userData) {
console.log($stateParams);
console.log($state);
// Problem: $state still points to the state you're navigating away from
});
}
}
});
});
Run Code Online (Sandbox Code Playgroud)