我遇到了angular2 v.2.4.0的问题,当我尝试导入类时,它叫我TS2304:找不到名称'HTTPTestService'(类的名称)代码component.ts
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
}
我也有第二类文件,效果很好,但我不想把所有课程都放进去,你能帮助我吗?
答案 0 :(得分:1)
import { HTTPTestService } from './json.service';