我有2项服务。第一个服务是http CRUD功能中的map功能。第二项服务只是提供第一项服务中提供的服务。
当我将第二个服务注入第一个服务时,Inject看起来像一个成功的构造函数第二个服务定义。
我在http CRUD map函数中调用了我的第一个服务函数中的函数,问题是第二个服务对象中的map函数为null。
我的来源如下。
服务类
@injectable()
export class AService {
constructor(private bs: BService){
console.log(this.bs); // that bs variable was defined
}
public parser(response: Response){
this.bs.dosometing(); // that bs variable was undefined
/* this function is http CRUD map function */
}
}
B服务等级
@injectable()
export class BService {
constructor(){
}
public dosomting(){
// do something
}
}
Http服务类
@injectable()
export class MyHttpServiceClass {
constructor(private as: AService,private http){
}
public httpRequest(): observable<any>{
return http.get(url)
.map(this.as.parser)
.catch(errorchecker);
}
}
我不确定问题是什么。
请你帮助我好吗?
定义类时拼写错误...
@injectable必须是@Injectable()