Pass parameter to Angular ng-include

前端 未结 4 2064
南笙
南笙 2020-12-29 01:26

I am trying to display a binary tree of elements, which I go through recursively with ng-include.

What is the difference between ng-init=\"item = item.left\"

4条回答
  •  隐瞒了意图╮
    2020-12-29 01:30

    Pass parameter to Angular ng-include

    You don't need that. all ng-include's sources have the same controller. So each view sees the same data.

    What is the difference between ng-init="item = item.left" and ng-repeat="item in item.left"

    [1]

    ng-init="item = item.left" means - creating new instance named item that equals to item.left. In other words you achieve the same by writing in controller:

    $scope.item = $scope.item.left
    

    [2]

    ng-repeat="item in item.left" means create list of scopes based on item.left array. You should know that each item in ng-repeat has its private scope


    I am trying to display a binary tree of elements, which I go through recursively with ng-include.

    I posted in the past answer how to display tree by using ng-include.

    It might helpful: how-do-display-a-collapsible-tree

    The main part here that you create Node with id wrapped by tag and use ng-repeat:

      
    
    
    

提交回复
热议问题