Middle
What types of data binding exist in Angular?
sobes.tech AI
Answer from AI
In Angular, the following data binding types exist:
-
One-Way Data Binding: Component to DOM: Changes in the component are reflected in the view (HTML).
-
Interpolation Binding: Displaying component property values.
<p>{{ componentProperty }}</p> -
Property Binding: Setting DOM element property values.
<img [src]="imageUrl">
-
-
One-Way Data Binding: DOM to Component: Changes in the view (user events) affect component properties.
-
Event Binding: Handling DOM element events.
<button (click)="handleClick()">Click me</button>
-
-
Two-Way Data Binding: Changes in the component and view affect each other simultaneously.
-
Uses the
[()]syntax.<input [(ngModel)]="userName"> -
Requires importing
FormsModuleforngModel.
-