[英]Can't use response in Component View from Subscribe, what is the alternative?
export class Component implements OnInit {
obj:string;
img:string;
username:string = '';
email:string;
bio:string;
constructor(private authService:AuthService) {
this.authService.user
.subscribe((userVal) => {
this.obj = JSON.stringify(userVal);
this.username = userVal.username;
console.log(this.username);
})
}
现在这不起作用,您可以记录响应但不能在组件视图中显示它
你可以在这里找到一些像这样的黑客: 更改订阅中的变量后,Angular 6 View 不会更新
此处提供的选项似乎都不起作用
有人有解决方案吗? 如果用任何明确的方式都不可能,那么 Angular 注定要失败
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.