Last active
November 26, 2015 19:34
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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