简体   繁体   中英

When to use template driven & reactive forms in Angular

I have read a lot of articles about the differences about the 2 types of forms in angular but nowhere found practical examples. So, if I have a table, and only a checkbox to select rows, is there any good reason to use reactive form? I can't find any reason not to use the template driven method.

Select row in a table with checkbox... Template or Reactive??

Search input above this table... Template or Reactive??

(No validation)

Ideally when you have something to do which takes the control back to the business logic, you should use reactive forms.

If you want something very short and sweet which is for eg, validating numbers or minLen or maxLen stuff, then template driven forms are the best. For complex validations, we may require to use reactive forms.

I hope this helps. Thank you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM