A
A
ar52016-11-18 13:32:22
Angular
ar5, 2016-11-18 13:32:22

How to pass data between components in Angular2?

Hello, friends. Consultation is needed on how to properly implement saving and passing data in Angular2. While a simple method is implemented, authorization occurs in service and is stored there as an object. It is possible to pull the method of this service, let's say userService.getUser () and it will return the user object to me.
I also saw when they save some data in the model itself. Tell me how to do it correctly?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeniy Samoilenko, 2016-11-18
@samoilenkoevgeniy

That's all there is to know about it.

A
Alexander, 2016-11-18
@alexbraun

To transfer data between components - @Input() @Output(), with this it is convenient to write reusable controls)
specify what data you want to store
1) If just to display View, then from the service, then to the model
2) if this is authentication, then store in localStorage user token, etc.)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question