【发布时间】:2017-09-05 11:28:53
【问题描述】:
大家好,我正在尝试在启动更改功能时清除我的 ng-model,但我的问题是我不想删除所有我想排除对象中的一项。
function change() {
if (vm.location.type) {
angular.forEach(vm.location, function (value, index) {
delete vm.location;
});
}
}
所以我不想删除
vm.location.type
我的
vm.location
有
vm.location.boundaries;
vm.location.region;
vm.location.address;
vm.location.name;
vm.location.nonVisitingRadius;
vm.location.visitingRadius;
【问题讨论】:
-
我不确定,你在尝试什么,但如果你想从对象中删除一个键,那么试试这样:
vm.location.region; -
我想做的是我想删除所有 vm.location 但我不想删除 vm.location.type 因为我仍然需要它
标签: angularjs angular-ngmodel angularjs-ng-change