Property binding in Angular
Nov 10, 2021
Property Binding help to bind values to the properties of the HTML elements. property binding is one way data binding technique. the square braces [] are used for binding the data to a property of an element. [property]
property binding allows us to bind a variable’s value from the component to a property in template.
Here is example, that explains property binding.
//HTML FILE<button [disabled] ="addUser">Add User</button>
<br><br>
<button (click)= "disableButton()">disable button</button>
<br>
<button (click)= "enableButton()">enable button</button>//TS FILEaddUser= false;
disableButton(){
this.addUser= true;
}enableButton(){
this.addUser= false;
}
Once you click enable button, Add User button will be enabled and when you click disable button, Add User button will be disabled.
Thanks for reading