Sunday, September 28, 2014

Did you know - AngularJS custom Service and Promise trivia

If you are writing a custom Angular service that says goes out and

  • does a $http.get() and
  • uses  .then() promise


the .then() promise will actually end up returning another promise that you can wire up to in your controller(where you are using this custom service). Also, note that in this scenario you are likely to use the revealing module pattern - like using a factory to return an object that you need instantiate, in order to use the custom service. This is different from the regular service singleton you get when using the built-in angular services.

1 comment: