I added the following property to my systemjs.config.js
map object in my Angular 2 app:
'@angular/http': 'https://npmcdn.com/@angular/http'
When I ctrl-click on the url it attempts to download a js file. However, when I try to import from '@angular/http
' at the top of my service.ts, the compiler returns the error "Cannot find module '@angular/http
'.`"
Is there an additional step that I'm missing in order for this module to be recognized and usable by my angular app? I'm using Angular version 2.0.0-rc.4.
To solve the error "Cannot find module '@angular/core'", make sure you have installed all dependencies by running the npm install command, set the baseUrl option to src in your tsconfig. json file and restart your IDE and development server.
Angular provides a client HTTP API for Angular applications, the HttpClient service class in @angular/common/http . The HTTP client service offers the following major features. The ability to request typed response objects. Streamlined error handling. Testability features.
The HttpClient is used to perform HTTP requests and it imported form @angular/common/http. The HttpClient is more modern and easy to use the alternative of HTTP. HttpClient is an improved replacement for Http. They expect to deprecate Http in Angular 5 and remove it in a later version.
run this in terminal:
npm install @angular/http@latest
Update for Angular 5+ versions:
import {HttpClientModule} from '@angular/common/http' import {HttpClient} from '@angular/common/http'
instead of HttpModule and Http respectively.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With