What are the practical differences between template-driven and reactive forms?

后端 未结 6 1583
遇见更好的自我
遇见更好的自我 2020-11-28 19:08

I have been reading about Angular2 new Forms API and it seems that there are two approaches on forms, one is Template driven forms other is reactive or model-driven forms.

6条回答
  •  时光取名叫无心
    2020-11-28 19:22

    I think that it´s a discussion about code, strategy and user experience.

    In summary we change for template-driven approach which is more easy to work with it, to reactive (in model-driven approach) for giving us more control, that results in a better testable form by leveraging a decoupling between the HTML (design/CSS team can work here) and component's business rules (angular/js specialist members) and to improve the user experience with features like reactive transformations, correlated validations and handle complex scenarios as runtime validation rules and dynamic fields duplication.

    This article is a good reference about it: Angular 2 Forms - Template Driven and Model Driven Approaches

提交回复
热议问题