Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 7 - Sharing Data

What is the best way to share data between components in Angular 7?

Can I use @Input and @Output only for components that are in the relation of child and parent?

like image 285
BiancaC Avatar asked Dec 05 '18 09:12

BiancaC


People also ask

How pass data from parent to child in Angularjs 7?

Otherwise, remember the three steps: Prepare Child component to emit data. Bind Property in Parent Component template. Use Property in Parent Component class.

Can be used to share common data between multiple components in Angular?

When we build components in an application, we maybe need to share or send data from parent to child or without a direct connection. Angular provides different these ways to communicate components: Using Input() and Output() decorators. Using Viewchild decorator.


1 Answers

If your components are not related,there are two solutions: you can use a shared service(using observable) or you can use ngrx/store.

like image 133
Eduard Vintu Avatar answered Sep 19 '22 16:09

Eduard Vintu