My Plunker.
In My plunker if I add some childs, then if I remove one of child record then if I add rows the rows are duplicating.
$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: []
});
};
Instead of adding nodeData.items.lenght add this for id
id: nodeData.items.length?(nodeData.items[nodeData.items.length-1].id)+1:nodeData.id * 10
And for rowId add this
rowId: nodeData.rowId + '.' + ((nodeData.items.length?(parseInt(nodeData.items[nodeData.items.length-1].rowId.split('.').pop()))+1:0)),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With