vesparny / angular-kickstart

angular-kickstart - speed up your AngularJS development and testing with a great gulpjs build system.
http://bit.ly/angular_kickstart
MIT License
552 stars 83 forks source link

Return $promise in route resolve #4

Closed lithammer closed 10 years ago

lithammer commented 10 years ago

Imagine the following code snippet:

function('NotesCtrl', function(notesList) {
    console.log(notesList);
}

Without returning $promise, this will always print []. However with $promise it will print the actual list of items returned from the server.

vesparny commented 10 years ago

Shouldn't controller be instantiated only when NotesService.Query() gets data? I'm not sure about that, this evening I'll investigate and merge your PR, thanks for that

lithammer commented 10 years ago

Here's what little documentation I could find about it:

$promise: the promise of the original server interaction that created this instance or collection.

On success, the promise is resolved with the same resource instance or collection object, updated with data from server. This makes it easy to use in resolve section of $routeProvider.when() to defer view rendering until the resource(s) are loaded.

http://docs.angularjs.org/api/ngResource.$resource

vesparny commented 10 years ago

Thanks for your contribution, I've mentioned you on the README.