javascript - angular 2 Do we need avoid two way databind when not necessary? -


i search lot understand if there bad performance if use 2 way databind (ng-model) times @ forms instead of 1 way databind. know angular 1 each 2 way databind new watch created , huge applications angular 1 can have performance issues because this. need know if angular 2 make difference if use 1 way databind or not? 2 way databind need avoid when not necessary?

angular2 doesn't have two-way data binding.

angular2 has

data-binding parent child

[childprop]="parentprop" 

when change detection detects change in parentprop updates childprop , calls ngonchanges() in child component (when implemented).

and event binding child parent

the way child parent event binding.

(childpropchange)="parentprop = $event" 

calls "someactiononparent()" when eventfromchild.emit(somevalue) called in child component.

the combination of these two syntactic sugar data , event bindings shown above

[(childprop)]="parentprop" 

this means change detection has check parentprop change , doesn't care other direction. update child parent has invoked actively child component , doesn't involve change detection.

this unidirectional data flow allows angular2's change detection extremely efficient. further optimize change detection use changedetectionstrategy.onpush in components. allows prune tree angular2 has change detection.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -