angular.js - Ask about deleting an object array from a multi-dimensional object array in angular
给我你的怀抱
给我你的怀抱 2017-05-15 16:59:30
0
2
647

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!

给我你的怀抱
给我你的怀抱

reply all(2)
大家讲道理
<p ng-repeat='comment in comments' ng-click='del($index,comments)'>{{comment}}</p>

$scope.delete=function(key,arr){
   arr.splice(key,1);
}
刘奇

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)
    }
})
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template