问题描述
我实际上是在组件中使用此代码来监听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对象内,每次我添加新主题时,它就会立即出现在列表中。但是没有课程,当我添加新课程时,我刚刚创建的课程不会出现在列表中。这是它的样子
保存后
如果刷新页面,则我的新课程不在列表中。不知道为什么在我的主题中就可以了,但是在我的课程中却不能。
在我点击保存后,我的服务为我提供了新数据,但没有提供我的课程,有人知道为什么吗?
解决方法
我修复了它,实际上它在对话框关闭后需要再次订阅,因此我在打开的对话框函数中添加了此代码this.getCurrentMateriLesson(this.materiSlug);