What is the difference between the types of binding in the Angular?

3

Non-Angular (non-AngularJS) there are some ways to bind Component properties to the View.

<img src="{{ boundProperty }}">
<img bind-src="boundProperty">
<img [src]="boundProperty">

Is there a proper way to perform bindings? In what situations should each of the above items be used and why?

    
asked by anonymous 22.09.2017 / 04:58

1 answer

2

There is no right way to perform Data Binding, each situation can be used the way you want and / or can apply. There are 4 ways:

  • Interpolation: {{ valor }}

    • associates component information for the template (HTML)
  • Property Binding: [propriedade]="valor"

    • associates component information for the template (HTML)
  • Event Binding: (evento)="handler"

    • associates template information (HTML) for component
  • Two-Way Data Binding: [(ngModel)]="propriedade"

    • associates information between both, that is, keeps both updated (component and template (HTML).
  • Source: link

        
    20.12.2017 / 17:43