AngularJS ngRepeat element removal

后端 未结 5 1267
迷失自我
迷失自我 2021-01-30 08:19

There are quite a few questions on how to implement item removal inside ngRepeat directive, and as I figured out, it comes down to using ngClick and triggering

5条回答
  •  死守一世寂寞
    2021-01-30 09:04

    If you have used ng-repeat on an object instead of an array, do the following.

    {{ email }} Remove
    {{ phone }} Remove
    $scope.remove = function(objects, o){ delete object[o.id]; }

    or the more terse

    {{ email }} Remove
    {{ phone }} Remove

    presumes that the objects look like this

    var emails = {  '123' : { id : '123', .... }  };
    
    var phones = {  '123' : { id : '123', .... }  };
    

提交回复
热议问题