How to remove an item from an array in AngularJS scope?

后端 未结 10 1751
梦毁少年i
梦毁少年i 2020-11-27 09:10

Simple to-do list, but with a delete button on list page for each item:

Relevant template HTML:


          


        
10条回答
  •  生来不讨喜
    2020-11-27 09:43

    You'll have to find the index of the person in your persons array, then use the array's splice method:

    $scope.persons.splice( $scope.persons.indexOf(person), 1 );
    

提交回复
热议问题