Q1. What are the types of data binding in Angular?
Angular provides four types: Interpolation ({{ }}) for one-way from component to template, Property binding ([property]="value") for setting element properties, Event binding ((event)="handler") for responding to user actions, and Two-way binding ([(ngModel)]) for bidirectional synchronization. These enable seamless communication between component and view.
Q2. What is property binding?
Property binding sets an element''s property from the component. Use square brackets around the property. Example:
The component property imageUrl provides the source. Property binding is one-way: component to view.Q3. What is event binding?
Event binding listens to DOM events and calls component methods. Use parentheses around the event name. Example:
The $event object contains event details. Event binding is one-way: view to component.Q4. What is two-way data binding?
Two-way binding combines property binding and event binding, synchronizing the view and component. It uses [(ngModel)] syntax, which requires FormsModule. Example:
Hello {{ username }}
Changes in input update the component, and vice versa.Q5. What is the difference between property binding and interpolation?
Interpolation ({{ }}) is a shorthand for property binding when the element property is text content. For non-string values or element properties, property binding is required. Interpolation always results in a string, while property binding can pass any type. Property binding is more explicit and powerful.
