在 http post 之后刷新组件
Refresh component after http post
我有一个添加新项目的模式(addProjectModal 组件)
save(data:Project) {
data.customer_id = this.customerID;
data.supervisor_id = 450;
this._projectService.addProject(data)
.subscribe(res => console.log(res)); //maybe init the refresh here
}
这个组件在我保存项目数据的projectComponent中使用
ngOnInit() {
this.collapsedItem = -1;
this._projectService.getProjects(this.customerID)
.subscribe(data => {
this.projects = data
});
}
如何告诉父组件刷新(从数据库请求新数据)?
我会说用
@Output()
为此...
因此 html 代码将如下所示:
<parentComponent>
<childComponent tellParent="parentFunction()"></childComponent>
</parentComponent>
我有一个添加新项目的模式(addProjectModal 组件)
save(data:Project) {
data.customer_id = this.customerID;
data.supervisor_id = 450;
this._projectService.addProject(data)
.subscribe(res => console.log(res)); //maybe init the refresh here
}
这个组件在我保存项目数据的projectComponent中使用
ngOnInit() {
this.collapsedItem = -1;
this._projectService.getProjects(this.customerID)
.subscribe(data => {
this.projects = data
});
}
如何告诉父组件刷新(从数据库请求新数据)?
我会说用
@Output()
为此...
因此 html 代码将如下所示:
<parentComponent>
<childComponent tellParent="parentFunction()"></childComponent>
</parentComponent>