typescript - How to bind Arrays in angular between components? -
problem
i have 2 child-components , 1 parent component. first child simple list of tasks, second map points showing whole project(project have list of tasks), have lots of interactions points on map, , need 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 handle onaddtaskmodalclose() event , getting project http.
first child component (list)
export class taskslistcomponent implements oninit { @output() ontaskschange: eventemitter<projecttask[]>; @input() 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 displaying data, projecttask huge model, , im changing 1 of values nested inside, doesn't fire setter (but other next problem).
second component (map)
this pretty simple component. map illustrate whole project , of points, , can add task component.
so need solution passing project.tasks 1 component (task-list-component using in couple of places in app) , when change values of tasks there, need show changes on map instantly. there simple way this?
Comments
Post a Comment