Javascript array push is not working -
i stuck on why array push not work... appreciated.
var addons = new array(); myservice.addon_dependencies(arr[i]['addoncode']).then(function(dependency) { console.log(dependency[0].addon_depend); //returns a6002 addons.push(dependency[0].addon_depend); }); console.log(addons); //returns []
this because addon_dependencies method not finishing before run console.log
. then
method shows you're using sort of promise framework. if print out in then
block should work.
Comments
Post a Comment