Angularjs Post-Receive Hook or Similar?

后端 未结 2 1641
南旧
南旧 2020-12-30 10:27

Is there a way to call a function every time after a response is returned from a server without explicitly calling it after in the callback?

The main purpose is that

2条回答
  •  隐瞒了意图╮
    2020-12-30 11:17

    If you mean for requests using $http or a $resource you can add generic error handling to responses by adding code to the $httpProvider.responseInterceptors. See more in this post.

    Although it is about starting/stopping spinners using this fiddle you can add your code in the 'stop spinner' section with // do something on error. Thanks to zdam from the groups!

提交回复
热议问题