Maison > Questions et réponses > le corps du texte
评论展示是ng-repeat,comment in comments。
有删除评论功能,ng-click之后,把comment传到删除函数里,然后从comments里把这个comment删掉,这个删除的语句应该怎么写呢?
谢谢!
大家讲道理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)
}
})