在Angular 4中调用Api一次并使用了许多组件?

在Angular 4中调用Api一次并使用了许多组件?,angular,angular4-forms,angular4-httpclient,Angular,Angular4 Forms,Angular4 Httpclient,我有两个组件Master和MasterDetails,还有一个服务名MasterService,第一次加载主组件时它工作正常,但是如果我导航到MasterDetails组件,我会得到空白响应如何解决它,请建议我 主元件 this.masterservice.abc(this.userid).subscribe(res=>{ this.shohinEditData=res; //在全局变量中设置SHOINEDIT数据 this.masterservice.setUserInfo(this.shoh

我有两个组件Master和MasterDetails,还有一个服务名MasterService,第一次加载主组件时它工作正常,但是如果我导航到MasterDetails组件,我会得到空白响应如何解决它,请建议我

主元件

this.masterservice.abc(this.userid).subscribe(res=>{
this.shohinEditData=res;
//在全局变量中设置SHOINEDIT数据
this.masterservice.setUserInfo(this.shohinEditData);
}
MasterDetails组件

构造函数(专用主服务:主服务){
this.masterservice.currentuserInfo.subscribe((userInfo)=>{(console.log(userInfo))});
}
万事达

private userInfo=新行为主体(“”);
currentuserInfo=this.userInfo.asObservable();
setuserInfo(userInfo:any){
this.userInfo.next(userInfo);
}

请分享一些代码,因为这确实是为了了解应用程序中的实际错误。同时发布你的app.routing.module请参阅上面的代码请分享你的代码,以便每个人都能正确理解你的问题。@Shubham我看不到它