AuthService with promise and cache
| angular.service('AuthService', function($q, $http) { | |
| var authStuff, promise; | |
| this.login = function(credentials) { | |
| if (!authStuff) { | |
| promise = $http.post(...).then(function(response) { authStuff = response.data; }); | |
| } | |
| return $q(function(resolve, reject) { | |
| promise.then(resolve(...)).catch(reject(...)); | |
| }); | |
| } | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
wesleycho commentedJan 6, 2016
Perhaps?