What is DATA-Binding in Angular? Different types of data binding with details examples and understanding
Hey Guys,
In this blog we are going to learn about data binding in angular with examples.What is a data binding?
- Data binding it's allows angular communication between a component and the DOM elements in angular.
- In angular, we have a total of 4 type of data binding we have.
Different types of data binding are below.
- Interpolation
- Property binding
- Event binding
- Two-way data binding
Interpolation :-
- We can use double curly braces ( {{}} ) for binding data.
- It's provide communication between the component file to html files.
- We can use the interpolation to bind dynamic value in html files.
- Examples :-
app.component.ts files
Property Binding :-
- It's used to help you to set values for properties of HTML elements or directives as well as.
- Syntax :- [property]="values"
Example:-
app.component.ts
Out put :-
Event Binding :-
- It's called once we call specific events inside a DOM element.
- Events are :- (click), (change), etc...
- Syntax: (eventName)="functionName()"
app.component.ts
Two-way Data Binding:-
- It's used for listening to events and updating value simultaneously for both parents and child components.
- Syntax: [(ngModel)]="values"
app.component.ts
If you guys have any query then you can drop a mail to us on this mail id:
techoswag@gmail.com
Comments
Post a Comment