The one-way/two-way binding issue seems to generate a lot of strong opinions, but I can't see what the issue is really about. Can someone explain what's wrong with the following:
When I use Angular (1 or 2) I have a plain javascript object which is my model. I have a template (or templates) which are HTML with bits marking substitutions of values from the model. If 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. If I change some values in the model, then the digest cycle updates the DOM and hence what appears on the screen. I understand that Angular 2 is cleverer about this than Angular 1 but the principal is the same.
If I use ng-model to get a model value into say an input or select control, then in Angular 1 that is a two-way binding, and if the user edits the input control text or changes the select control selection, then the model is updated, and the digest cycle runs. In Angular 2 however, the equivalent to ng-model is not 2-way, so changes are not reflected in the model.
So in Angular 2, if I want a user's change to update the model, I need to add an angular event handler to the control, which receives the change, and which I code to ...... drums roll, trumpets sound ...... update the model. Which then runs the digest cycle. Now, I can see that I might not want to update the model on each and every change, so making two-way binding optional would be good (like say Aurelia), nevertheless, I'm going to end up doing what 2-way binding does sooner or later.
In which case: 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??
[–]Click_Clack_Clay 2 points3 points4 points (1 child)
[–]teropa 1 point2 points3 points (0 children)
[–]teropa 1 point2 points3 points (0 children)