Error: This is the error I am getting even thought I have added provider to mine component.I am unable to get what\'s the mine error for. here are mine all file app.component.t
You don't need to provide the Response, it's a reference generated by the Http itself. In the early days of alpha version I faced the same error and solved it using this line: constructor(@Inject(Http) http : Http)
.
In the constructor of your CarService just add @Inject and tell us if it solves your problem.
carservice.ts becomes:
import { Inject, Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
@Injectable()
export class CarService {
constructor(@Inject(Http) http : Http) {}
getCarsMedium() {
return this.http.get('app/resources/data/cars-medium.json')
.toPromise()
.then(res => <Car[]> res.json().data)
.then(data => { return data; });
}
}
export interface Car {
label;
value;
}
Response
depends on ResponseOptions
and ResponseOptions
is not designed in a way it can be injected easily. See https://github.com/angular/angular/blob/bb8976608db93b9ff90a71187608a4390cbd7a07/modules/%40angular/http/src/base_response_options.ts#L57
If you are injecting Response
somewhere then you're probably doing something that is not supposed to work this way.