Javascript 使用嵌套中继器的ng repeat start和ng repeat end
我尝试使用ng repeat遍历嵌套的树状数组 HTML 我的问题是,我需要一种方法来确定我何时在数组中某个特定级别的最后一项中,但由于Angular通过先深入来遵循递归,因此我不能使用Javascript 使用嵌套中继器的ng repeat start和ng repeat end,javascript,angularjs,Javascript,Angularjs,我尝试使用ng repeat遍历嵌套的树状数组 HTML 我的问题是,我需要一种方法来确定我何时在数组中某个特定级别的最后一项中,但由于Angular通过先深入来遵循递归,因此我不能使用ng repeat start和ng repeat end: 当然,预期的结果是: 我如何知道我是否在某个特定级别的末尾?您可以使用$last确定每次迭代的结束时间: <div ng-show="$last" ng-repeat-end>End of repeater</div> 中
ng repeat start
和ng repeat end
:
当然,预期的结果是:
我如何知道我是否在某个特定级别的末尾?您可以使用
$last
确定每次迭代的结束时间:
<div ng-show="$last" ng-repeat-end>End of repeater</div>
中继器结束
这给了我你问题的后一个结果
var myApp = angular.module('myApp', []);
myApp.directive('layout', function() {
return {
templateUrl: 'layout',
controller: function($scope) {
$scope.data = {
'nodes': [
{
'name': 'layout',
'nodes': [{'name': 'box'}, {'name': 'box'}, {'name': 'box'}, {'name': 'box'}]
},
{
'name': 'layout',
'nodes': [{'name': 'box'}, {'name': 'box'}, {'name': 'box'}, {'name': 'box'}]
}
]
}
}
}
})
<div ng-show="$last" ng-repeat-end>End of repeater</div>