Comment display is ng-repeat, comment in comments.
There is a function to delete comments. After ng-click, the comment is passed to the delete function, and then the comment is deleted from comments. How should the delete statement be written?
Thank you!
大家讲道理2017-05-15 17:01:30
<p ng-repeat='comment in comments' ng-click='del($index,comments)'>{{comment}}</p>
$scope.delete=function(key,arr){
arr.splice(key,1);
}
怪我咯2017-05-15 17:01:30
html
<p ng-repeat='comment in comments' ng-click='delete($index)'>{{comment}}</p>
js
app.controller('myCtrl', function($scope) {
$scope.comments=[1,2,3,4]
$scope.delete=function(i){
$scope.comments.splice(i,1)
}
})