2017-06-28 5 views
0

Hier im Versuch passieren id Wert meiner Api Bitte helfen Sie mir Wie ich pass i schrieb Code alsWie id URL in Angular 2

**StateUrl: "http://localhost:54873/Api/Home/GetStates"** This is my url i wana 2 pass it By using my value This is my code 

GetStatesById(id: number): Observable<State> { 
      const stsurlById = `${this.StateUrl}/${id}`; 
      return 
      this._http.get(stsurlById).map(this.extractData).catch(this.handleError) 
     } 

Hier im immer Fehler als nicht erreichbar Code dected

Antwort

1
schreiben

pase reffer diesen code

GetStatesById(id: number): Observable<State> { 
     const url = `${this.StateUrl}/${id}`; 
     return this._http.get(url) 
      .map(this.extractData) 
      // .do(data => console.log('getProduct: ' + JSON.stringify(data))) 
      .catch(this.handleError); 
    } 
+0

vielen dank es ist wirklich gut – Hussain