It could be a common case that we need to show an error/success message to the user after he updates/creates some data, how can we implement it in AngularJS?
I want to add callbacks but could not find a solution. Using $http.post().success().error() works, but I wonder if I can do it with the higher lever API $resource.
Or, we should write directives or use $watch()?
Thanks for your help in advance.
It could be a common case that we need to show an error/success message
Share
Actions from the Resource class can be passed success and error callbacks just like the lower level $http service
From the docs
Non-get actions are prefixed with
$.So you can do this
Edit: here’s another example from a previous plunker. The get request will fail since it request a non existing json file. The error callback will be run.