Angular 2 Forms: Template Syntax vs Model Driven
A co-worker of mine asked whether I was using template syntax or model driven for the forms I was building. My response was a squinty eye stare. Then I replied that I was following the same examples as the angular.io docs showed. Apparently that means I’m using template syntax. Other than some syntactic differences; banana in a box [(ngModel)] and the fact that we no longer use dashes for things; it’s pretty similar to what any angular 1 developer has done before.
After re-reading the angular.io forms documentation, then reading part way through the ng-book forms guide (honestly that guide is hooge, and I’m still working my way through it) I came across an excellent post by jhades that goes through the differences in language that I understood.
My current understanding is that the model driven approach brings us two benefits.
- Testability of forms and validation
- A more programmatic approach to forms
The second part is the one that interests me the most. I’ve been hear about reactive programming for a while and how angular 2 supports this and I should really get into it. (Honestly though I’m a bit behind the curve and need to catch up on other new things first before I get into reactive. I’m working on it though I promise). Two points that jhades makes is really what perked my attention.
pre-save the form in the background at each valid state
typical desktop features like undo/redo
If this can make it easier to allow us web developers to add undo/redo a little easier maybe I need to move up my time table on getting to know reactive programming better.
Until then there are only so many programming hours in me per day.
-mark