在敏近的HTML模板中,可观察的值不会更改

发布于 2025-02-11 18:23:14 字数 332 浏览 2 评论 0原文

在我的ngonint中,我正在调用脚本,该值在console.log中显示,但在HTML模板中不反映。用户列表在模板中为空。

getAllRoles(){
     this.adminService
    .getAllRoles().subscribe((users: any) => {
      this.userList =  users;
    });
    console.log("now",this.userList)
  }

in my ngOnint I am calling the script, the value is showing in console.log but not reflecting in html template. userList is empty in template.

getAllRoles(){
     this.adminService
    .getAllRoles().subscribe((users: any) => {
      this.userList =  users;
    });
    console.log("now",this.userList)
  }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最冷一天 2025-02-18 18:23:14

您能尝试一下:

getAllRoles(){
    this.adminService.getAllRoles().pipe(take(1)).subscribe((users: any) => {
      this.userList = [...users];
      console.log("now",this.userList);
    });
}

Can you try this:

getAllRoles(){
    this.adminService.getAllRoles().pipe(take(1)).subscribe((users: any) => {
      this.userList = [...users];
      console.log("now",this.userList);
    });
}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文