我有一个模态来添加一个新项目(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
});
}
您如何告诉父组件刷新(从数据库请求新数据)?
答案 0 :(得分:3)
我会说要使用
@Output()
为此...
所以html代码看起来像这样:
<parentComponent>
<childComponent tellParent="parentFunction()"></childComponent>
</parentComponent>