我想在现有阵列中动态添加新阵列。这里我尝试将数组添加到共享服务中的现有数组中。如何将新阵列动态添加到现有阵列中
这里是我的代码
var shareService = angular.module('ibaDataService', []);
shareService.service('shareData', function() {
this.comonData = [];
this.tabData = [];
this.pushArray = function (arrayName) {
//this.comonData.push(arrayName[]);
// here i want to add commonData.newArray[]
}
});
谢谢,它在arrayName [] – Ajith
右边显示一些语法错误,移除'[]'使它变成'self.comonData.push(arrayName);' – Filype
Filype,我把数组名称设置为“new”,但是icant访问this.comonData.new。 – Ajith