Cathy
Cathy

Reputation: 377

Rows data should be existing while adding empty rows to table using Angularjs

Basically, I am adding empty rows to table which is working in angular-1.0.1.js but when im using same function using angular-1.2.13.js only 1 row is adding if i tried to add another row it's not working.

Link1 above example is using angular-1.0.1, Link2 this code is using angular-1.2.13 and the row data should be retrieving also like "Link1" code. I tried to combine both examples Link3 here is solution i got.Can any one tel me how to add multiple rows.

I am new to this and started working on angularjs from past 3 days, hope I gave an clear explanation.

Upvotes: 0

Views: 833

Answers (1)

null
null

Reputation: 7926

I'm not quite sure why this isn't working with 1.2.13 but either changing the ng-repeat to ...

fruit in fruits track by $index

... or changing both the ng-click and the associate function to ...

<button ng-click="addFruit(newFruit)">Add</button>

$scope.addFruit=function(newFruit){
  $scope.fruits.push(newFruit);
}

... will do the trick.

Upvotes: 1

Related Questions