2017-02-17 13 views
0

私は http://courses.angularclass.com/courses/enrolled/73288エラー:NoteServiceのすべてのパラメータを解決できません:

から角度2のビデオチュートリアルを追っていると私は私のAPIを実行すると、上記のエラーがアップします(?)。

次は

`

import {Injectable} from '@angular/core'; 
import {Headers, Http, Response} from '@angular/http'; 
import {Observable} from 'rxjs/Observable'; 
import 'rxjs/Rx'; 
import 'rxjs/add/observable/throw'; 

@Injectable() 
export class ApiService{ 
    headers: Headers=new Headers({ 
     'Cotent-Type': 'application/json', 
     Accept: 'application/json' 
    }); 

    api_url: string = 'http://localhost:3500'; 

    constructor(private http: Http){ 

    } 

    private getJson(resp: Response){ 
     return resp.json(); 
    } 
    private checkForError(resp: Response): Response{ 
     if(resp.status >=200 && resp.status<300){ 
      return resp; 
     } 
     else{ 
      const error=new Error(resp.statusText); 
      error['response']= resp; 
      console.error(error); 
      throw error; 
     } 
    } 
    get(path: string): Observable<any>{ 
     return this.http.get(`${this.api_url}${path}`, this.headers) 
     .map(this.checkForError) 
     .catch(err=> Observable.throw(err)) 
     .map(this.getJson) 
    } 

    post(path: string, body): Observable<any>{ 
     return this.http.post(
       `${this.api_url}${path}`, 
       JSON.stringify(body), 
       {headers: this.headers} 
     ) 
     .map(this.checkForError) 
     .catch(err=> Observable.throw(err)) 
     .map(this.getJson); 
    } 
    delete(path: string): Observable<any>{ 
     return this.http.delete(`${this.api_url}${path}`, this.headers) 
     .map(this.checkForError) 
     .catch(err=> Observable.throw(err)) 
     .map(this.getJson) 
    } 
} 
、ブラウザによると、未解決のパラメータ

`

import {Injectable} from '@angular/core'; 
import { ApiService } from './api'; 


export class NoteService{ 
    path: string= '/notes'; 
    constructor(private api: ApiService) {} 
    createNote(note){ 
     return this.api.post(this.path, note); 
    } 
    getNotes(){ 
     return this.api.get(this.path); 
    } 

    completeNote(note){ 
     return this.api.delete(`${this.path}/${note.id}`); 
    } 
}` 

を持っており、これは、ウェブページ用のAPIサービスであるサービスです

'

質問に他のファイルを含める必要がある場合は、コメントに記載してください。 ありがとうございます。

+0

あなたはどこで 'ApiService'と' NoteService'を提供しましたか? 'HttpModule'をインポートしましたか? –

答えて

0
@Injectable() // required when a service has constructor parameters 
export class NoteService{ 
関連する問題