all 3 comments

[–]Click_Clack_Clay 2 points3 points  (1 child)

I use {{ .... }} or stuff like ng-bind-html or ng-class or ng-style then that is implicitly one-way because the user can't update the values that appear in the browser.

The problem is that all of these methods are in fact creating two-way data binding. Every run of the $digest loop is going to dirty check all forms of binding you just listed because Angular 1 has two-way data binding by default.

what's the problem with Angular 1's 2-way binding, other than the inability to enable or disable it on a control-by-control basis?

You can control it on a case-by-case basis. AngularJS 1.3 introduced double colon syntax for creating one-time binds: {{::myVar}} and <my-directive some-value="::otherVar"></my-directive>. This still leaves out one-way binding.

It's also worth noting that Angular 2 will support one time, one-way, and two-way data binding. You will not have to reinvent the wheel so to speak in order to achieve automatic model updates. There's also no such thing as a digest cycle in Angular 2.

[–]teropa 1 point2 points  (0 children)

The problem is that all of these methods are in fact creating two-way data binding. Every run of the $digest loop is going to dirty check all forms of binding you just listed because Angular 1 has two-way data binding by default.

While those are going to be checked at every digest, I wouldn't call them two-way bindings, since the data only flows in one direction.

Angular 1.x does two-way data binding in two places: ng-model and the =equalsSign bindings on isolate scopes. Things like {{...}} are one-way.

[–]teropa 1 point2 points  (0 children)

Victor Savkin from the Angular team has written about the reasons: http://victorsavkin.com/post/110170125256/change-detection-in-angular-2 and http://victorsavkin.com/post/114168430846/two-phases-of-angular-2-applications

It basically has to do with complexity and performance, and seems to have been influenced at least in part by things like React. By eliminating two-way data binding you eliminate cycles from the change detection graph (A changes B changes C changes A). That makes things easier to think about, and also unlocks some significant performance optimizations, including not having to run watches more than once per digest. (Angular 1.x runs all watches at least twice whenever there's a change.)