-1
저는 ApiEndpoint라는 주사 서비스가 있습니다. 나는이 문제를 직면하고 있지만 다른 클래스의 내부에서이 서비스를 사용해야합니다.다른 클래스에 서비스 주입 - Angular2
코드는 다음과 같이 간다 : 우리가 'group.ts'을 가져 할
import {ApiEndpoint} from './apiEndpoint';
export class Group {
public name: string;
constructor(){}
save(){
ApiEndpoint.createGroup(); <== ERROR
}
}
몇 군데
//apiEndpoint.ts
@Injectable()
export class ApiEndpoint {
constructor(private _http: Http) {}
createGroup() { this._http...)
}
//group.ts을 다음
let myGroup = new Group();
myGroup.name = 'foo';
myGroup.save();
다음 오류가 나타납니다.
Property 'createGroup' does not exist on type 'typeof ApiEndpoint'.
어떻게 해결할 수 있습니까?