P
P
Pogran2016-11-14 15:40:51
Angular
Pogran, 2016-11-14 15:40:51

How to pass value from child to parent?

I'm trying to make a relationship 1.child - 2.parent - 3.child.
Two children are inherited from 1 parent, but the data must be transferred first from one child to the parent, and then from the parent to the child, because the children are not related to each other.
I manage to make a connection from parent to child, there I use @Input():
@Input() isSearch: boolean = false;
in the parent I receive it and give it like this
The question is how can I pass this headerSearch value to the parent from another child?
I hope I wrote clearly. As I understand it, there is @Output () - but it is in order to listen to events, and when loading, I just need to pass a boolean value

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Klusevich, 2016-11-14
@Pogran

You can do it through the service. A service instance is created in which the value is stored. One child is connected to services using data-binding, the second one requests via a method.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question