In Angular 1 using ng-bind
gave you a performance boost over interpolation.
Is this still the case in Angular 2? Should I use [innerText]
over interpolation.
E.g.
<p>{{slower}}</p>
<p [innerText]="faster"></p>
We often have a choice between interpolation and property binding. The following binding pairs do the same thing:
Interpolated: <img src="{{vehicle.imageUrl}}"><br> Property bound: <img [src]="vehicle.imageUrl"> The interpolated title is {{title}} [innerHTML]="'The [innerHTML] title is '+title">
Interpolation is a convenient alternative for property binding in many cases. In fact, Angular translates those interpolations into the corresponding property bindings before rendering the view.
There is no technical reason to prefer one form to the other. We lean toward readability, which tends to favor interpolation. We suggest establishing coding style rules and choosing the form that both conforms to the rules and feels most natural for the task at hand.
Source: https://angular.io/docs/ts/latest/guide/template-syntax.html#!#property-binding
So you can use anyone. Hope this will help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With