Skip to content

Instantly share code, notes, and snippets.

@khoand0000
Last active November 26, 2015 19:34
Show Gist options
  • Save khoand0000/aab3d4051dbaee77147a to your computer and use it in GitHub Desktop.
Save khoand0000/aab3d4051dbaee77147a to your computer and use it in GitHub Desktop.
Using angular.forEach to loop array that is returned $promise. Because result contains more information of angularjs: $promise, $resolved
// data is array
vm.data = Data.getData(function () {
angular.forEach(vm.data, function(item) {
console.log(item);
});
// don't use
// for (var i = 0; i < vm.data.length; i++)
// { }
// or don't use
// for (var index in vm.data) {}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment