【发布时间】:2019-12-03 11:52:48
【问题描述】:
事情是这样的。我想用这个控制器在 angular.forEach 中用 if-else 条件覆盖一个对象,基本上“k1”有一个原始关键字,我想用一个新关键字替换它。您认为显示新输入对象的最佳方式是什么?
$scope.SubmitKeyword = function (key, new_keyword) {
console.log(key, new_keyword)
$scope.new_keyword = new_keyword;
if ($scope.new_keyword == null || $scope.new_keyword == undefined || $scope.new_keyword == "") {
alert('Invalid input!')
return
}
angular.forEach($scope.new_campaign_keywords, function (v, k) {
console.log(v,k)
if (k == key) {
if (v['orig_keyword'] == new_keyword) {
alert('No Changes Found!')
return
} else {
console.log('changes detected')
var a = 0;
angular.forEach($scope.campaigns, function (v1,k1) {
a++
console.log(k1)
if (k1 == a) {
//display the new keyword
else {
//remain the original keyword
}
}
})
}
}
})
};
【问题讨论】:
标签: javascript angularjs object