我正在尝试将 Angular.js 服务回调中的值推送到数组中。任何帮助,将不胜感激。谢谢。
$scope.checkAddonDependencies = function(addon) {
var addons = new Array();
var arr = filterFilter($scope.addons, {checked: true});
var length = arr.length, element = null;
for (var i = 0; i < length; i++) {
element = arr[i]['addoncode'];
addons.push(element); //works fine
myService.addon_dependencies(arr[i]['addoncode']).then(function(dependency) {
addons.push(dependency); //not working
});
}
console.log(addons);
}