【发布时间】:2018-08-29 17:11:50
【问题描述】:
我正在尝试将我的数据推送到此CompareArray,但出现以下错误:
TypeError: Cannot read property 'push' of undefined
at Object.addResult (src\services\CompareService.js:22)
代码:
this.addResult = function (type, result) {
this[type.toLowerCase() + 'CompareArray'].push(result);
this.checkToDisplayLinks(type);
this.checkToDisableCheckboxes(type);
};
【问题讨论】:
-
表示
this[type.toLowerCase() + 'CompareArray']未定义
标签: javascript arrays angularjs