K
K
Konstantin2020-10-09 22:54:35
Angular
Konstantin, 2020-10-09 22:54:35

How to make linked lists?

I have a custom component - which internally fills the select list field with a request via autocomplete.

<app-search-reon [searchType]="'CADNUM'" (onSelected)="onCadnumSelected($event)"></app-search-reon>


There are also two others - performing a different request:

<app-search-reon [searchType]="'C'" (onSelected)="onCadnumSelected($event)"></app-search-reon>
 <app-search-reon [searchType]="'D'" (onSelected)="onCadnumSelected($event)"></app-search-reon>


Each of the components has an output with the value `onCadnumSelected($event)` selected from the list. From which data can be extracted.

How, when onCadnumSelected($event) of one of the components is triggered, to push the received data into another such component?

You can use Input (), you can go through ViewChildren, or maybe the architecture is wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Shvedov, 2020-10-09
@Junart1

Make a service, in it BehaviorSubject with data, subscribe to it in all components, and change, or rather make a method in the service to change the data, and give it out of the service as BehaviorSubject.asObservable();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question