How to transfer data between components in angular 2

From the child to the parent, I know through EventEmitter, but if I have many deeply nested components, how do I do it?

 0
Author: Nazar Kalytiuk, 2017-02-10

2 answers

It seems to me that the easiest way to do this is through the service. And in the component where you will need to use this data, import this service in the constructor and display the necessary data in the template. If I understood the question correctly..=)

 0
Author: Александр Лонский, 2017-04-15 17:12:54
  1. Using the @Input directive https://metanit.com/web/angular2/2.7.php
  2. Using the services https://metanit.com/web/angular2/4.3.php and subscribe to events

Https://habrahabr.ru/post/318480/

  1. Using static classes and subscribing to events or a list with the necessary components

Angular 2 EventEmitter event is called, but the data is not updated

 0
Author: Serginio, 2017-04-06 14:46:01