0

I am new in Angular2. I read many articles on model driven vs template driven. There are some advantages/disadvantages on both approaches so my question is that which one is better to start a new project.

I also read below links:

http://blog.angular-university.io/introduction-to-angular-2-forms-template-driven-vs-model-driven/

https://www.codeproject.com/Tips/1166952/Angular-Forms-Template-driven-and-Model-driven-a

Thanks, Hitesh Paghadal

LuckyStarr
  • 1,468
  • 2
  • 26
  • 39
Hitesh
  • 1,188
  • 5
  • 30
  • 52
  • depends what you can understand better. although model driven seems fine to me. – Jai Mar 03 '17 at 11:17
  • 1
    Simple template, no unit testing => template driven. Complex template, unit testing => model driven. It's far more simple to debug a code in component than a mess in html... My two cents – mickdev Mar 03 '17 at 11:25

2 Answers2

0

If you are going to start the project it doesn't matter you'll use template as internal or external if you use AOT (Ahead of time) compilation it'll move all your external templates to internal. I'll prefer internal templating because you can see both code/template in same file and in large projects you can minimize the number of files and reduce the time of rendering the view. Good luck!

http://blog.mgechev.com/2016/08/14/ahead-of-time-compilation-angular-offline-precompilation/

Babar Hussain
  • 2,917
  • 1
  • 17
  • 14
0

Template Driven Forms Features

  • Easy to use (like simple login forms)

  • Suitable for simple scenarios

  • Two way data binding(using [(NgModel)] syntax)

  • Minimal component code (cause of 2 way data binding)

  • Automatic track of the form and its data(handled by Angular)

  • Unit testing is hard [cause data flow(tracking of the form data) is handle by the angular]

Reactive Forms Features

  • More flexible, but needs a lot of practice
  • No data binding is done
  • Easier unit testing

Now according to your situation use the best option

Check out this question for more info

Sumit
  • 529
  • 5
  • 13