Skip to content

Instantly share code, notes, and snippets.

@chandermani
Created February 1, 2014 17:32
Show Gist options
  • Save chandermani/8755571 to your computer and use it in GitHub Desktop.
Save chandermani/8755571 to your computer and use it in GitHub Desktop.
//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