【发布时间】:2015-11-05 00:34:39
【问题描述】:
我正在尝试更新 angular forEach 内的外部变量。这是代码。
var resultMap = {};
angular.forEach(originalMap, function(value, key) {
resultMap[key] = value;
}, resultMap);
console.log(resultMap);
不知道为什么 resultMap 在执行 forEach 块后还是空的。我有什么遗漏的吗?
更新—— 为简单起见,我没有在这里提到整个代码。在forEach里面我会写一些条件来填充resultMap。
【问题讨论】:
标签: javascript angularjs scope angularjs-scope