Surya Teja Surya Teja - 1 month ago 14
TypeScript Question

what is the difference between event binding and property binding?

In the architecture of angular 2 there are two terms Event binding and Property binding. What is the difference between them?Architecture of Angular2

Answer

Property binding -

In case you have to pass the value from parent component to child component (whether the value is static or dynamic) we have to use the property binding that mean by doing so we send the value using attribute on component and get there in the parent using @Input annotation for example of property binding see here -

<my-child [myProp]="prop" />

Event Binding -

Catching the Child's Event/method from the parent component

whenever we have to fire some event on click or something else from child component and pass to the parent one we have to use Event Binding see here in the example below -

<my-child [myProp]="prop" (onPropChange)="onPropChange($event)"</strong> />

here we have user onPropChange as event binding we can catch and fire that event using EventEmitter.

for more detail see here