Passing data from parent to child component in Angular: Passing objects and arrays (Hindi/Urdu)

Posted by

How To Pass Data From Parent To Child Component In Angular

कैसे Angular में Parent से Child Component में डेटा पास करें

Angular में डेटा को पैस करने का सबसे अच्छा तरीका है @Input डेकोरेटर का उपयोग करना। यहाँ हम देखेंगे कि कैसे हम अबीकलarray और ऑब्जेक्ट्स को पास कर सकते हैं।

स्टेप 1: Parent Component में डेटा भेजने के लिए @Input डेकोरेटर का उपयोग करें

Parent Component में, डेटा को चाइल्ड में पास करने के लिए @Input डेकोरेटर का उपयोग करें।

स्टेप 2: Child Component में प्राप्त करें डेटा

Child Component में, @Input डेकोरेटर का उपयोग करें और पैरेंट से डेटा प्राप्त करें।

उदाहरण:

    
    // parent.component.ts
    import { Component } from '@angular/core';

    @Component({
      selector: 'app-parent',
      template: `
        <app-child [data]="'Hello, World'">
      `
    })
    export class ParentComponent {}

    // child.component.ts
    import { Component, Input } from '@angular/core';

    @Component({
      selector: 'app-child',
      template: `
        <p>{{ data }}

` }) export class ChildComponent { @Input() data: any; }

ऊपर के उदाहरण में, Parent Component में ‘Hello, World’ डेटा को Child Component में पास किया गया है और Child Component में वह डेटा प्रिंट किया गया है।

इस तरह से, आप Angular में Parent से Child Component में डेटा पास कर सकते हैं।

0 0 votes
Article Rating

Leave a Reply

11 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@monusingh-jz6er
20 days ago

Really very well explained❤❤

@user-ov7ul5df1i
20 days ago

How to send multiple data ,
By single use of child component in parent component

@SHEFAT-xq3ge
20 days ago

i want to pass data from Mat-table row clicked,
<tr class="mat-row" mat-row *matRowDef="let row; columns: displayedColumns;"

(click) = "onRowClicked(row)" ></tr>
please help me

@jenytandel1342
20 days ago

Awesome sir very good explaination😍

@ahmedali-cb3eu
20 days ago

very nice tutorial

@kumars9844
20 days ago

one of the best lecture for angular …..if anyone searching for best angular tutorial then you are in right path bro….his way of explanation is awsome..and thanks sir

@user-is4nn4rr8f
20 days ago

v.nice playlist easyway to learn …

@krishna_9804
20 days ago

Finally Understood this topic. Thank you so much !!

@ChoudharyFaizan007
20 days ago

Thank you for uploading all these videos continuously

@kisanrathod9488
20 days ago

Awesm lècture..sir ❤❤👍👍😊😊

@FarazAhmed-zd2nq
20 days ago

Informative Sir ❤

11
0
Would love your thoughts, please comment.x
()
x