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?
Otherwise, remember the three steps: Prepare Child component to emit data. Bind Property in Parent Component template. Use Property in Parent Component class.
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.
If your components are not related,there are two solutions: you can use a shared service(using observable) or you can use ngrx/store.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With