I have a problem with Angular after I upgraded it from version 4 to version 5. I can’t use httpclient
anymore.
Here are screenshots with the list of my npm packages and the contents of the package.json
file:
I have a problem with Angular after I upgraded it from version 4 to version 5. I can’t use httpclient
anymore.
Here are screenshots with the list of my npm packages and the contents of the package.json
file:
I can see that you're using vs2017
do it like this
open cmd and type this cd 'location_of_your_project'
then type this
npm install @angular/common@5.0.0 @angular/compiler@5.0.0 @angular/compiler-cli@5.0.0 @angular/core@5.0.0 @angular/forms@5.0.0 @angular/http@5.0.0 @angular/platform-browser@5.0.0 @angular/platform-browser-dynamic@5.0.0 @angular/platform-server@5.0.0 @angular/router@5.0.0 @angular/animations@5.0.0 --save-dev
In app.module.ts
import HttpClientModule
from @angular/common/http
like this:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpClientModule } from '@angular/common/http';
import { AppComponent } from './app.component';
@NgModule({
imports: [ BrowserModule, HttpClientModule ],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
Then in your component
or service
you can import HttpClient
from `@angular/common/http' and use it by injection into construction.