在添加/更新数据库角度后收听更改

问题描述

我实际上是在组件中使用此代码来监听api

constructor(){
this.userService.listen().subscribe(
      (m: any) => {
        this.getCurrentMateriDetail();
        }
      }
    )
}
getCurrentMateriDetail() {
    return this.userService.getAdminMateriDetail(this.slug).subscribe(
      data => {
        this.getMateri = data;
        this.currentMateri = this.getMateri.data;
        this.editMateri.patchValue(this.currentMateri);
        this.getCurrentPemateri(this.pemateriCode);
        this.materiSlug = this.currentMateri.slug;
        this.getCurrentMateriLesson(this.materiSlug);
      },error => {
        // console.log(error);
      }
    )
  }

我真正想听的是LESSON,本课在TOPIC对象内,每次我添加主题时,它就会立即出现在列表中。但是没有课程,当我添加新课程时,我刚刚创建的课程不会出现在列表中。这是它的样子

enter image description here

保存后

enter image description here

如果刷新页面,则我的新课程不在列表中。不知道为什么在我的主题中就可以了,但是在我的课程中却不能。

这是我添加主题后的回复

enter image description here

在我点击保存后,我的服务为我提供了新数据,但没有提供我的课程,有人知道为什么吗?

解决方法

我修复了它,实际上它在对话框关闭后需要再次订阅,因此我在打开的对话框函数中添加了此代码this.getCurrentMateriLesson(this.materiSlug);

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...