Created
March 2, 2017 14:29
-
-
Save brunokrebs/7ba9434d2e43cf412592bfa4edd8f14e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... other imports | |
import { Http, RequestOptions } from '@angular/http'; | |
import { AuthHttp, AuthConfig } from 'angular2-jwt'; | |
import { TaskListService } from './task-list/task-list.service'; | |
// creates a factory to AuthHttp | |
export function authHttpFactory(http: Http, options: RequestOptions) { | |
return new AuthHttp(new AuthConfig(), http, options); | |
} | |
@NgModule({ | |
// ... other properties | |
providers: [ | |
AuthService, | |
TaskListService, // adds new service | |
{ | |
provide: AuthHttp, | |
useFactory: authHttpFactory, // defines how to provide AuthHttp | |
deps: [ Http, RequestOptions ] | |
} | |
], | |
bootstrap: [AppComponent] | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment