Skip to content

Instantly share code, notes, and snippets.

@elpddev
Last active August 28, 2020 20:20
Show Gist options
  • Save elpddev/4dca604878e70a47cc0129512d01fb0d to your computer and use it in GitHub Desktop.
Save elpddev/4dca604878e70a47cc0129512d01fb0d to your computer and use it in GitHub Desktop.
Auth Service #angularjs #medium #article-hierarchical-di-ng
class AuthService {
static $inject = ['$http'];
private token: string;
constructor($http: IHttpService) {}
getToken() {
if (_.isNil(this.token)) {
this.token = $http.get('my-site.example.com/auth');
}
return this.token;
}
}
moviesApp.service('auth', AuthService);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment