shrestha rohit
shrestha rohit

Reputation: 2940

passing object from ng-repeat

<td ng-repeat="data in data_legend" rowspan="2"></td>

Here , the data_legend is a dynamic array filled by user from the Form.Now the idea is to display all the dynamic content to the user and i need to know which element in the array is edited ?

Any Help will be appreciated :)

Upvotes: 1

Views: 725

Answers (1)

KpTheConstructor
KpTheConstructor

Reputation: 3291

You can pass current data in iteration to a function .

Example :

//Here I'm passing the current data object in array and its index to editData().

//$index will provide you the location of this data in array

<table ng-repeat="data in data_legend">
  <tr rowspan="2" ng-click="editData(data, $index)">
    <td>{{data.name}}</td>
    <td>{{data.price}}</td> 
    <td>{{data.year}}</td>
  </tr>
</table>

$scope.editData = function(data,index){

//Do something to data 

}

Hope this helps

Upvotes: 1

Related Questions