what is the difference between event binding and property binding?

后端 未结 2 776
情深已故
情深已故 2021-02-08 12:33

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

2条回答
  •  既然无缘
    2021-02-08 13:07

    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 receive it in the child component by using @Input decorator for example of property binding see here -

    
    

    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 component, we have to use Event Binding see here in the example below -

    
    

    here we have onPropChange as output event binding, we can fire that event using EventEmitter.

    for more detail see here

    • http://errietta.me/blog/angular2-property-event-binding/
    • https://www.patrickschadler.com/property-event-binding-angular-2/

提交回复
热议问题