typescript - Changing angular 2 services to HttpClient structure broke the application -
i updated services using {httpclient} @angular/common/http instead of {http, response} @angular/http
all services migrated following structure:
import {injectable} '@angular/core'; import {httpclient} '@angular/common/http'; @injectable() export class exampleservice { private readonly productsapi = '/products'; // url products list api private _initdata: iproduct[] = null; constructor(private http: httpclient, private sharedservice: sharedservice) { } getproducdetail(productid?: number): observable<iproduct> { const apiproductdetail = `${this.productsapi}/${productid}`; return this.http.get<any>(apiproductdetail) .map(initdata => this.extractproductdetail(initdata, productid)); } }
it works , compiles no errors, when deploy app web server shows following error in console:
error registering service worker: domexception: secure origins allowed
uncaught error: cannot resolve parameters 't'(?). make sure parameters decorated inject or have valid type annotations , 't' decorated injectable.
wiki
Comments
Post a Comment