⊗jsagPmCMCPP 62 of 97 menu

Passing Props to Child Component in Angular

You can also pass properties from a parent component to a child component. Let's see how this is done. In the parent component, we'll set the properties that we'll pass to the child component:

class AppComponent { public name: string = 'john'; public age: number = 25; }

In the parent template, we take the attribute names into square properties. In this case, what is written as the attribute value will be interpreted as a property of the parent class:

<user-data [name]="name" [age]="age"></user-data>

In the parent component, create properties for the product name and price. Pass their values ​​to your child component.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline