Sunday, 3 November 2019

What are different ways to pass data from one component to other component ?


There are several techniques to pass data between components in angular. If the components are nested, then there is a parent child relationship between those components. 

To pass data from the parent to child component we use input properties

To pass data from the child component to parent component we can either use output properties or template reference variables. 

Below is the summery:

Passing data from Parent Component to Child Component

Input Properties (@Input())

Passing data from Child Component to Parent Component

Output Properties (@Output())
Template Reference Variables

Passing data from Component to Component (No parent child relation)

Angular Service
Required Route Parameters
Optional Route Parameters
Query Parameters

No comments:

Post a Comment