I have a simple service like heroService:
import { Headers, Http } from '@angular/http';
@Injectable()
export class HeroService {
constructor(private http: Http) { }
getHeroes(): Promise<Hero[]> {
return this.http.get(this.heroesUrl)
.toPromise()
.then(response => response.json().data as Hero[])
.catch(this.handleError);
}
It works great when starting an ng service, however, if I create with prod or run "ng serve -prod" this.http undefined. I am importing httpModule into my application, so I donโt know why it doesnโt know what it is.
Does anyone know if I missed something, or is this a mistake?
source
share