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\">
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
: