javascript - AngularJS: automatically chaining $resource actions -
I have an AngularJS processing implementation, which (in principle) works fine. Now the special circumstances are:
- The resource's field (the attribute) is "The last time is the timestamp"
- If it comes to the server to update it,
- Updating methods on the server are implemented in every way, that the response is empty (instead of keeping the modified unit)
In situations, after the update operation from the server, "last timestone To get "Mapping", I have to get it immediately after the update immediately.
myEntity $ update (function () {myEntity. Get $);});
The question now is: AngularJS automatically provides a way of chain actions:
- Defining MyEntity Definition For that, he always needs to get $ after the $ update.
-
And then, call in the application code
myEntitty. $ Update ();
Thanks for @Mark to push me right direction. The solution is basically
var MyEntity = $ resource (..., {get: {...}, update: {...}}); // params have been passed for $ updates // After successful $ update, a parameters obtained is called // success called successful $ get // after the error that if $ update or $ fails So $ // MyEntity.prototype goes $ Assures $ assurance $ updateAndRefresh = function (param, success, error) {var item = this; Return items $ Update (parameter, function () {item. $ (Success, error);}, error); }
Comments
Post a Comment