Reputation: 271
Good day, I'm trying to create tree list from list of items with parent and childs id, that I recursive find with angular material based on following link http://codepen.io/dunmaksim/pen/GJLogo/, but there is something wrong in my code. Child level depends on item.expanded.
<script type="text/ng-template" id="dirtyDataFromServer.html">
<md-list-item flex>
<md-checkbox aria-label="item" ng-model='item.checked' md-indeterminate="isIndeterminate(item, $event)" ng-click="toggleChildrenChekboxes(item, $event)"></md-checkbox>
<label>{{ item.id }}. {{ item.name }}</label>
<span flex></span>
<md-icon style="z-index:100" class="material-icons">
<i ng-click="toggleItems(item, $event)" class="material-icons">{{item.expanded ? 'expand_less' : 'expand_more' }}</i>
</md-icon>
</md-list-item>
<md-list flex ng-show="item.expanded">
<div class="list-left-margin" ng-repeat="item in item.subObjs" ng-include="'dirtyDataFromServer.html'"></div>
</md-list>
</script>
So, whats happens here
1.item 1
2.item 2
3.item 3
4.item 4
6.item 6
7.item 7
5.item 5
but when I expand, for example item 4:
1.item 1
2.item 2
3.item 3
4.item 4
6.item 6
7.item 7
6.item 6
7.item 7
5.item 5
It create dubble at same level, items are simmilar, but in DOM they are different.
Upvotes: 2
Views: 2949