0
私はangle2 v。2.4.0に問題があります。クラスをインポートしようとすると、それが私に呼び出されます。TS2304:名前 'HTTPTestService'(クラス名)が見つかりません。コードは名前 'myobject'が見つかりませんAngular2
import { Component } from '@angular/core';
import { PictureRegister } from '../student.data';
import { HTTPTestService } from 'json.service';
@Component({
moduleId: module.id.toString(),
selector: 'student-register',
templateUrl: 'student-register.component.html',
providers: [
PictureRegister,
HTTPTestService
]
})
export class StudentRegisterComponent {
constructor(
pictureRegister: PictureRegister,
httpJSON: HTTPTestService //Here is error
)
とservice.ts
import {Injectable} from '@angular/core';
@Injectable()
export class HTTPTestService{
constructor (_http: Http)
{
this.httpJSON = _http;
}
//etc
}
をcomponent.ts私もうまく機能2番目のクラスファイルを、得たが、私はそれにすべてのクラスを置きたいと思ういけない、あなたは私を助けることができますか?
ひどくインポートするためです。 './service.ts 'から' import {HTTPTestService}を使ってみてください; – trichetriche
ファイルはjson.service.tsと呼ばれていますか? – thardes2