Friday, November 10, 2023

Data Binding - Property Binding

 b) Property Binding (.ts --> .html)

To set the property of an element in view to a property defined in the component's class

  1. Property Vs Attribute:
  2. Attributes and properties are not the same
  3. Attributes are defined by HTML
  4. Properties are defined by DOM
  5. Attribute values can not be change once they are initialized.
  6. Property values can change


public name="Sai Krishna"

public isDisabled : boolean = false


<input type="text" value={{name}} id={{name}}>
<input type="text" [value]="name" [id]="name">

<input type="text" [value]="name" [id]="name" disabled>
<input type="text" [value]="name" [id]="name" disabled={{isDisabled}}>
<input type="text" [value]="name" [id]="name" [disabled]="isDisabled">

No comments:

Post a Comment