5 ms·
Ugh, but this is just terrible: <input type="checkbox" ng-model="todo.done"> I guess I'm a purist.
by aerolite 14y ago
Ugh, but this is just terrible:
<input type="checkbox" ng-model="todo.done">
I guess I'm a purist.
- deleted 14y ago[deleted]
- testing12341234 14y agoAngular supports many styles of markup. Other valid forms of that snippet are: Using xml namespace: <input type="checkbox" ng:model="todo.done"> Using underscore in the attribute name: <input type="checkbox" ng_model="todo.done"> As an x-* attribute: <input type="checkbox" x-ng-model="todo.done"> As a HTML5 data attribute: <input type="checkbox" data-ng-model="todo.done"> I think their may be a few more, but in any case, Angular is flexible enough that you can choose the representation that is best for you and your team.
- joshuacc 14y agoWhat about it do you find terrible? The declarative nature of the binding? Or just the fact that it isn't valid according to the HTML spec?
- aerolite 14y agoIt's invalid HTML and it's destroying the separation between logic and presentation/content.
- woadwarrior01 14y agoThis was a deal-breaker me, when I was evaluating Angular and Ember ~6 months ago. I eventually chose Ember and things worked out pretty well.
- tlarkworthy 14y agoYou must like bloating your project with pages of trivial javascript accomplishing trivial functionality. I really don't want basic stuff in my application logic. Allowing users to flip arbitrary booleans is a bit like declaring a public variable though. You can of course make them go through a setter if you prefer encapsulation. <input type="checkbox" ng-click="setDone($event.target.checked)">