【发布时间】:2016-03-08 21:38:15
【问题描述】:
当我删除dataItem 时,我已经存在对象值数组,dataItem 具有与selectedOwners 相同的属性,所以如果dataItem 选择的值匹配,我想从selectedOwners 数组中删除该对象。
我如何使用 AngularJs 或 Javascript 来完成这项任务?
ctrl.js
var selectedOwners = [{"fullName":"Johnson, Rocio","workerKey":3506},{"fullName":"Johnson, John S.","workerKey":571}];
$scope.deleteOwner = function(dataItem){
angular.forEach(selectedOwners,function(val,index){
if(val === dataItem){
selectedOwners.splice(index,1);
}
})
}
【问题讨论】:
标签: javascript arrays angularjs