1
votes

I have a modal to add a new project (addProjectModal component)

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
}

This component is used in projectComponent where I hold the project data

ngOnInit() {
  this.collapsedItem = -1;
  this._projectService.getProjects(this.customerID)
    .subscribe(data => {
      this.projects = data
    });
}

How would you tell the parent component to refresh (request the new data from database)?

1

1 Answers

3
votes

I will say to use

@Output()

for this...

So html code will look like this:

<parentComponent>
     <childComponent tellParent="parentFunction()"></childComponent>
</parentComponent>