4
我的Angular控制器內有一個Node
對象。每個Node
有next
屬性,它指向下一個項目:鏈接數據對象中的ng-repeat
$scope.Stack = function() {
this.top = null;
this.rear = null;
this.size = 0;
this.max_size = 15;
};
$scope.Node = function (data) {
this.data = data;
this.next = null;
this.previous = null;
};
$scope.Stack.prototype.pushUp = function (data) {
for (i = 0; i < data.items.length; i++) {
if (data.items[i]) {
var node = new $scope.Node(data.items[i]);
if (node) {
node.previous = this.top;
if (this.top) {
this.top.next = node;
}
this.top = node;
// if first push, the set the rear
if (this.size == 0) {
this.rear = node;
}
this.size += 1;
}
}
}
};
創建對象:
$scope.Timeline = new $scope.Stack();
我的問題:有沒有辦法來遍歷這樣的鏈接的數據結構採用NG-重複/角?
ng-repeat只能迭代官方JavaScript集合(即數組和鍵值對)。 – Claies