Created
February 1, 2014 17:32
-
-
Save chandermani/8755571 to your computer and use it in GitHub Desktop.
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
//The incorrect way | |
var employees=$resource('url').query(); //this is async call. Return value of the call is a empty array [] | |
console.log(employees.length); //This is immediately executed so length is 0. Data gets filled in future. | |
//Right way | |
$resource('url').query().then(function(data) { | |
employees = data; | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment