Ng-repeat in a related data object

I have an object Nodeinside my Angular controller. Each Nodehas a property nextthat points to the following element:

$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;
                }
            }
        }

    };

Object Creation:

$scope.Timeline = new $scope.Stack();

My question is: is there a way to iterate over related data structures like this using ng-repeat / Angular?

+4
source share
1 answer

According to AngularJS docs

variable in expression - where the variable is a user-defined loop variable, and the expression is a scope expression that allows the collection to be counted.

ngRepeat Javascript "Collection". , , . : "", .

+1

Source: https://habr.com/ru/post/1598615/


All Articles