Hi!
I guess that the best practice depends on the application use-cases
really. If you want to have always the latest data after save issuing
the .query() call after save makes sense. If, on the other hand,
people are not interested by updates coming from other sources (other
users of an app) than I would just update local array with a new
record.
In any case I would update a local array _only after I'm sure that the
DB call succeeded_ (which in case of $resource means doing this is the
success callback). I would advice against updating a local array first
and doing "silent" call to DB as things can get confusing in case in
save failures. Moreover a persistent data store will often generate a
unique key that should be part of the save object.
Cheers,
Pawel
> --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To post to this group, send email to
ang...@googlegroups.com.
> To unsubscribe from this group, send email to
>
angular+u...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/angular?hl=en.
>
>
--
Question? Send a fiddle
(
http://jsfiddle.net/pkozlowski_opensource/Q2NpJ/) or a plunk
(
http://plnkr.co/)
Need help with jsFiddle? Check this:
http://pkozlowskios.wordpress.com/2012/08/12/using-jsfiddle-with-angularjs/
Looking for UI widget library for AngularJS? Here you go:
http://angular-ui.github.com/