0

There is an excellent Q&A on displaying a global loader in an AngularJS application whenever an HTTP request is made. Is there a way to determine if there is an element associated with the call via a controller (I'm thinking of a directive or the ngController attribute)? I'd like to be able to cover the specific element with a loader.

If that isn't feasible, is there a better solution that having the relevant controllers track whether or not they've made a call and pass that to a loader directive? Ex:

<div ng-controller="MyController as mc" my-loader="mc.loading">
Community
  • 1
  • 1
ricksmt
  • 888
  • 2
  • 13
  • 34
  • If the loader directive returns a Promise, then you can bind controller-specific-loader to its state. To be more specific - which of the examples in http://stackoverflow.com/questions/15033195/showing-spinner-gif-during-http-request-in-angular you're trying to adopt? – shershen May 20 '16 at 19:02
  • I'm not trying to adopt any of those per say. The follow up question in the second paragraph proposes a variation of [this answer](http://stackoverflow.com/a/15033322/1680677) where the loader implementation is handled by a directive. My first questions is wondering if I can go from $http to $element and thus handle the loader in an interceptor or something like that. – ricksmt May 20 '16 at 19:12

0 Answers0