Can I code a "finally" with AngularJS resource version 1.2.3?

angularjs

Solution

There Should be a `$promise` property on your `entityResource`. You should be able to set `finally` there.

entityResource.$promise['finally'](function(){
  // finally do something
});

see docs

update: You could do something like this:

//Using the promise on your resource.
function success(){/**success*/};
function error(){/**failure*/};
function last(){/**finally*/};
entityResource.save(data,success,error).$promise.finally(last);

By using angular's `$q` and `.then` You will invoke a `$digest` cycle. Which will update your view, which is usually fantastic.

Problem

I have the following code using AngularJS resource: ``` var entityResource = $resource('/api/:et/', { et: $scope.entityType }); entityResource.save(data, function (result) { // code $scope.modal.submitDisabled = false; }, function (result) { // code $scope.modal.submitDisabled = false; }); ``` Is there something like a finally that I can use so I can put the code to disable (and my other code) outside of the success and error? Also can I now use .success and .error or do I still have to code as two functions inside () ? I did notice changes in 1.2.3 but I am not sure if I understand how these apply.

Original source