Created
February 11, 2019 16:12
-
-
Save bbachi/1cc09e4113b3446efdf41ec6414cba63 to your computer and use it in GitHub Desktop.
New way of using Http in Angular
This file contains 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
import { HttpClientModule } from '@angular/common/http'; | |
@NgModule({ | |
declarations: [ | |
AppComponent | |
], | |
imports: [ | |
HttpClientModule, | |
], | |
providers: [], | |
bootstrap: [ AppComponent ] | |
}) | |
export class AppModule { } |
This file contains 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
import { HttpClient } from '@angular/common/http'; | |
@Injectable() | |
export class AppService implements OnInit { | |
constructor(private http: HttpClient) {} | |
ngOnInit(){ | |
this.appConfig = this.http.get(this.configUrl); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment