javascript - Access HTML Parent, Child, Sibling elements in Angular JS -
$scope.delete = function(){ here want t.number };
<li class="item" ng-repeat="t in items"> <div class="row"> <div class="col col-10"><i></i></div> <div class="col col-70"> <span class="number">{{t.number}}</span> <p class="date">{{t.date}}</p> </div> <div class="col col-20"> <i class="ion ion-ios-paper" ng-click="details()"></i> <i class="ion ion-trash-a" ng-click="delete()"></i> </div> </div> </li>
please guide me how access html elements in angular js controllers.
here need in ng-click="delete(items, $index)'
<li class="item" ng-repeat="t in items"> <div class="row"> <div class="col col-10"><i></i></div> <div class="col col-70"> <span class="number">{{t.number}}</span> <p class="date">{{t.date}}</p> </div> <div class="col col-20"> <i class="ion ion-ios-paper" ng-click="details()"></i> <i class="ion ion-trash-a" ng-click="delete(items, $index)"></i> </div> </div> </li>
then, in controller:
$scope.delete = function(array, index){ console.log('item number: ',index); // element number array.splice(index, 1); // delete element };
and explain it, in ng-click
, send array name items
in case , index
(location in array), delete
function get's array want delete , position of item in array
Comments
Post a Comment