Issue
I am having arrays of array as response
[
[
"i-091a5dosdobs2",
"t2.nano",
"running"
],
[
"i-03dd8duhud9",
"t2.micro",
"running"
]
]
I am using ng-repeat and rendering the data into table
<tbody>
<tr ng-repeat="datas in data" >
<td ng-repeat="d in datas">
{{d}}
</td>
<td>
<button class="btn btn-primary" ng-click="close(d)">Close</button>
</td>
</tr>
</tbody>
I want button in all the rows which can able to close that particular instance but how to do it ? in json we can do with key. How can I do it here ?
Solution
You only need to pass the ec2 instance ID which is d[0]
<button class="btn btn-primary" ng-click="close(d[0])">Close</button>
and your close function would be like
$scope.close = function(id) {
// factory send ajax to close the instance ... then
let index = $scope.data.findIndex((i)=> i[0]===id)
$scope.data.splice(index,1); // this would remove the item from your table
}
Answered By - Kinglish
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.