How to the child to parent data pass in angular – 2024

In this article, we will learn about how to pass data from child to parent in angular

Solution 1: angular passing data to child component


Parent component:
<app-child-component [item]="data"></app-child-component>

Child component.ts
import { Component, Input } from '@angular/core'; // First, import Input
export class ItemDetailComponent {
  @Input() item = ''; // decorate the property with @Input()

Solution 2: parent to child data pass in angular

<h1>this is perent component</h1>
<app-child [items]="employee"></app-child>
 employee = {
    id: 1,
    name: 'chintan',
    address: 'junagadh',
@Input() items: any;
<h2>{{ }}</h2>
<h2>{{ }}</h2>
<h2>{{ items.address }}</h2>

Discover more from STRUGGLER KING.COM

Subscribe now to keep reading and get access to the full archive.

Continue Reading