⊗jsagPmTpPAB 20 of 97 menu

Binding Values ​​to DOM Element Properties in Angular

In Angular, there are two types of binding values ​​to tags: to a tag attribute and to a DOM element property. As a rule, these are the same thing, but sometimes they matter.

Let's look at these two methods with examples. Let's say we have the following class property:

export class AppComponent { public text: string = 'abcde'; }

Let's output the value of this property to text textarea

<textarea>{{ text }}</textarea>

And now in the attribute placeholder:

<textarea placeholder="{{ text }}"></textarea>

Now let's write the data to the DOM element property. To do this, we'll put the attribute name in square brackets:

<textarea [value]="text"></textarea>

Given an input, write down its property data value.

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