Sunday, 3 November 2019

What is data binding in angular?


A component in Angular is a class with a template and a decorator. So, in simple terms a component in Angular is composed of these 3 things i.e. Template (.html file), Class (.ts file), Decorator (@component at the top. If not decorated it will behave as simple class not as an component).

In some cases, we need to pass data form view template to component and component to view. For this we need to bind the data between them. In angular data binding is of two types.

One-way data binding  From Component to View Template (Interpolation and Property binding, attribute binding)

One-way data binding  From View Template to Component (at time data will pass in one direction not in both direction)

Two-way data binding  From Component to View Template & From View template to Component (Data will pass in both direction)


No comments:

Post a Comment