Problem
I have 2 child-components and 1 parent component. First child is a simple list of tasks, second is map with points that showing whole project(project have list of Tasks), i have lots of interactions with points on the map, and i need to bind array of tasks between components.
Main Component
HTML:
<app-tasks-list [(TasksList)]="Project.Tasks"></app-tasks-list>
<app-map [project]="Project" (onAddTaskModalClose)="addTaskToList($event)"></app-map>
TS: In Typescript file I only handle onAddTaskModalClose() event and getting project from http.
First child Component (list)
export class TasksListComponent implements OnInit {
@Output() onTasksChange: EventEmitter<ProjectTask[]>;
@Input()
get TasksList() {
return this.Tasks
}
set TasksList(TasksList: ProjectTask[]) {
this.Tasks = TasksList;
this.onTasksChange.emit(this.Tasks)
}
private Tasks: Array<ProjectTask> = [];
}
In HTML I'm using TasksList getter for displaying data, ProjectTask is a huge Model, and sometimes im only changing one of the values nested inside, which doesn't fire setter (but this is other next problem).
Second Component (map)
This is pretty simple component. Map that illustrate whole project and all of his points, and also i can add task from this component.
So i need a solution for passing Project.Tasks to one component (task-list-component is using in couple of places in my app) and when i change values of those tasks there, I need to show this changes on map instantly. Is there any simple way for this?