{"id":156,"date":"2018-03-04T00:21:09","date_gmt":"2018-03-04T00:21:09","guid":{"rendered":"http:\/\/www.bhoomabrsr.com\/blog\/?p=156"},"modified":"2019-11-11T02:11:51","modified_gmt":"2019-11-11T02:11:51","slug":"template-driven-forms-api-angular-v5-x","status":"publish","type":"post","link":"https:\/\/www.bhoomabrsr.com\/blog\/index.php\/2018\/03\/04\/template-driven-forms-api-angular-v5-x\/","title":{"rendered":"Template Driven Forms API &#8211; Angular v5.x"},"content":{"rendered":"<p>Angular has rich form support regarding both template driven and reactive forms. This article is going to focus only on the template-driven forms and validations.<br \/>\n<strong>Template-Driven Forms :<\/strong><br \/>\n<em>Definition:<\/em><br \/>\nAngular will create FormGrop and FormControl objects based on applied directives like <em>ngForm, ngModel, ngModelGroup<\/em> and template reference variables from a form template.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-161\" src=\"https:\/\/www.bhoomabrsr.com\/blog\/wp-content\/uploads\/2018\/03\/templateDIR2.png\" alt=\"\" width=\"184\" height=\"114\" \/><br \/>\n<strong>TEMPLATE DRIVEN DIRECTIVES:<\/strong><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-160\" src=\"https:\/\/www.bhoomabrsr.com\/blog\/wp-content\/uploads\/2018\/03\/templateDIR.png\" alt=\"\" width=\"600\" height=\"28\" \/><br \/>\nAll above directives are available once we import <em>FormsModule<\/em> into application NgModule.<br \/>\n<strong>NgForm<\/strong> &#8211; Will create a top-level FormGroup instance and binds it to a form to track updates\/validations.<br \/>\n<strong>NgModel<\/strong> &#8211; Will Creates a FormControl instance and will track input field value, events and validation rules.it will keep view and model in sync.<br \/>\n<strong>NgModelGroup<\/strong> &#8211; Will create a sub-group form controller to maintain nested structured model.<br \/>\nSimply:<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-162\" src=\"https:\/\/www.bhoomabrsr.com\/blog\/wp-content\/uploads\/2018\/03\/templateforms.jpg\" alt=\"\" width=\"3600\" height=\"2400\" \/><br \/>\nExample: <a href=\"https:\/\/plnkr.co\/edit\/kvwKCX19MvTWcSQMAHn7?p=preview\">Live Example<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Angular has rich form support regarding both template driven and reactive forms. This article is going to focus only on the template-driven forms and validations. Template-Driven Forms : Definition: Angular will create FormGrop and FormControl&hellip; <a href=\"https:\/\/www.bhoomabrsr.com\/blog\/index.php\/2018\/03\/04\/template-driven-forms-api-angular-v5-x\/\">More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,4,5,1],"tags":[22,23],"class_list":["post-156","post","type-post","status-publish","format-standard","hentry","category-angular","category-angular-5-2-6","category-angular-v5-x","category-uncategorized","tag-angular-v5","tag-angular-v5-2-6"],"_links":{"self":[{"href":"https:\/\/www.bhoomabrsr.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/156","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bhoomabrsr.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bhoomabrsr.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bhoomabrsr.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bhoomabrsr.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=156"}],"version-history":[{"count":2,"href":"https:\/\/www.bhoomabrsr.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/156\/revisions"}],"predecessor-version":[{"id":200,"href":"https:\/\/www.bhoomabrsr.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/156\/revisions\/200"}],"wp:attachment":[{"href":"https:\/\/www.bhoomabrsr.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bhoomabrsr.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bhoomabrsr.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}