A
A
alexandrtym2017-08-27 00:41:44
Angular
alexandrtym, 2017-08-27 00:41:44

How can you pass data from one child component to another?

Hello. I just started learning Angular. There was a question of transferring data from one child component to another child component (from a method of one component, a method is triggered in another). I know that data is transferred using Iput, Output, VievChild and so on. Unfortunately, I do not know how best to transfer data in my case. I would be grateful for practical examples of how these directives work or links to examples. Thank you in advance.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dasha Tsiklauri, 2017-08-27
@dasha_programmist

Zayuzay dependency injection
In the parent component, you make provide of your own type, inherited from subject, in the child in the constructor you use the same instance and prescribe for changes. For some reason, few people use this approach, apparently due to poor documentation.

F
furrya_black, 2017-08-28
@furrya_black

If data is needed throughout the application, user token, nickname - then statement with offline second - redux and localforage for example, otherwise Subject.
Look at app/service/message.service and loader.service here - https://bitbucket.org/furrya_black/cake-shop

N
Negwereth, 2017-08-27
@Negwereth

Pull the event to the parent component, in which there will be an event handler, in which, through the @Input property of the second, pass the value.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question