How to increment parent row dynamically in angular ui tree

Viewed 208

Plunker.

In this plunker I have maintained + and ++. + for increment the parent rows and ++ for increment the child rows.

Here ++ is incrementing correctly. and '+' also incrementing correctly, if I click on ++ then it will add one child row for parent.

then if I click on + button for it should add another child row for parent. but it is adding another main row.

Here I got the perticular row with this keyword in html. Like that How can I get parent object of the child row what we have clicked.

ng-click="newSubItem(this)"//here This keyword will give the current object.

controller:-

$scope.newSubItem = function(scope) {
      var nodeData = scope.$modelValue;
      nodeData.items.push({
        id: nodeData.id * 10 + nodeData.items.length,
        rowId: nodeData.rowId + '.' + (nodeData.items.length + 1),
        items: []
      });
    };

Like this I want to increment the current object and push into the items[] array.so The current object will comes under parent object.

Finally how can I get the parent object of the current object.

1 Answers
Related