{"id":1128,"date":"2023-06-30T05:00:00","date_gmt":"2023-06-30T12:00:00","guid":{"rendered":"https:\/\/www.angulartraining.com\/daily-newsletter\/?p=1128"},"modified":"2023-06-28T15:26:17","modified_gmt":"2023-06-28T22:26:17","slug":"reactive-or-template-driven-forms","status":"publish","type":"post","link":"https:\/\/www.angulartraining.com\/daily-newsletter\/reactive-or-template-driven-forms\/","title":{"rendered":"Reactive or template-driven forms?"},"content":{"rendered":"\n<p>People are often conflicted when it comes down to forms with Angular. Should we use template-driven forms or reactive forms?<\/p>\n\n\n\n<p>Here&#8217;s a simple answer:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If your form is <strong>dynamic<\/strong> (meaning: if the user selects this option, then add\/enable or remove\/disable other form elements) or will rely on <strong>RxJs for reactivity<\/strong> (meaning: auto-complete features or on-the-fly validation of user input using HTTP requests), then use <a href=\"https:\/\/angular.io\/guide\/reactive-forms\" target=\"_blank\" rel=\"noopener\" title=\"\">reactive forms<\/a>.<\/li>\n\n\n\n<li>In all other scenarios, <a href=\"https:\/\/angular.io\/guide\/forms\" target=\"_blank\" rel=\"noopener\" title=\"\">template-driven forms<\/a> should be perfectly fine.<\/li>\n<\/ul>\n\n\n\n<p>That&#8217;s it. A bonus for you: If you want to have custom validation of your form, use this <a href=\"https:\/\/www.angulartraining.com\/daily-newsletter\/using-validation-functions-that-work-with-both-template-driven-and-reactive-forms\/\" target=\"_blank\" rel=\"noopener\" title=\"\">tutorial to implement custom validation that works with both template-driven and reactive forms<\/a>, so you&#8217;re not tied to a single option and can still change your mind later on.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>People are often conflicted when it comes down to forms with Angular. Should we use template-driven forms or reactive forms? Here&#8217;s a simple answer: That&#8217;s it. A bonus for you: If you want to have custom validation of your form, use this tutorial to implement custom validation that works with both template-driven and reactive forms, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,22,10],"tags":[],"class_list":["post-1128","post","type-post","status-publish","format-standard","hentry","category-angular","category-forms","category-rxjs"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/1128","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/comments?post=1128"}],"version-history":[{"count":2,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/1128\/revisions"}],"predecessor-version":[{"id":1143,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/posts\/1128\/revisions\/1143"}],"wp:attachment":[{"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/media?parent=1128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/categories?post=1128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.angulartraining.com\/daily-newsletter\/wp-json\/wp\/v2\/tags?post=1128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}