<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Enz-a - Medium]]></title>
        <description><![CDATA[Knowledge is essential for education. Book, Article, Newspapers and e-doc, etc provide huge knowledge for the people who wish to gain wide knowledge. These articles are basically to distribute the knowledge for knowledge seekers. - Medium]]></description>
        <link>https://medium.com/enz-a?source=rss----2e4167b052fe---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Enz-a - Medium</title>
            <link>https://medium.com/enz-a?source=rss----2e4167b052fe---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 06:14:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/enz-a" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Angular Forms Guide II — How to develop the basic Reactive & Template-driven Forms]]></title>
            <link>https://medium.com/enz-a/angular-forms-guide-ii-how-to-develop-the-basic-reactive-template-driven-forms-9a72a8651a07?source=rss----2e4167b052fe---4</link>
            <guid isPermaLink="false">https://medium.com/p/9a72a8651a07</guid>
            <dc:creator><![CDATA[Nadeesha Dilrukshi]]></dc:creator>
            <pubDate>Tue, 26 Jan 2021 11:38:34 GMT</pubDate>
            <atom:updated>2021-02-01T03:05:10.222Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Angular Forms Guide II — How to develop the basic Reactive &amp; Template-driven Forms</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*yvXEtHg4VEdCy0m1fYXxsQ.png" /></figure><p>This article on the medium is regarding implement the basic Angular reactive form &amp; Template-driven form. I search for the easiest and most understandable article. The available articles didn’t guide me to a clear solution. Therefore, I thought of filling the gap with this article, which will provide complete guidance for developed the simple Angular forms. To get the difference between these forms please refer my first article on the medium, <a href="https://medium.com/enz-a/angular-forms-guide-reactive-forms-vs-template-driven-form-32abdb1b7c5?source=friends_link&amp;sk=6018ce5ed411e8436670cdb98a99bea9"><strong>“Angular Forms Guide — Reactive Forms Vs. Template-driven Form”</strong></a></p><p>Let’s start at….</p><h3>Template-driven form</h3><pre>C:\Users\user&gt; ng new template-drivenForm</pre><p>Using this angular command you can create the new project to develop the template-driven form, by this process it installing the dependencies such as Node.js, npm.</p><pre>C:\Users\user\template-drivenForm&gt; ng serve</pre><p>The above command flag opens up the browser automatically. This angular command gives the URL to open your project on the browser.</p><h4>As an example — <a href="http://localhost:4200/">http://localhost:4200/</a></h4><p>So, now we successfully create our first angular project.</p><p>okay then let’s move to our code editor and opens up the created project.</p><p>To get access to all features of Template-driven form you need to import the <strong>form-Module</strong> into our <strong>root-module.</strong></p><p><strong>src/app/app.module.ts</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3a7bcb159285a4c79a8d192f6d90a43e/href">https://medium.com/media/3a7bcb159285a4c79a8d192f6d90a43e/href</a></iframe><p>The purpose of the app.module.ts is it import the formModule in our app.module.ts.</p><p>So we can create a very simple html form with bootstrap/css in our app. component to capture the <strong>User Data. </strong>So in your <strong><em>index.html, </em></strong>make sure that you have a reference to bootstrap.</p><p>Then go back to your <strong>app.componet.ts</strong> file.</p><p><strong>src/app/app.component.ts</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eec33368d30c960329247d83735687a2/href">https://medium.com/media/eec33368d30c960329247d83735687a2/href</a></iframe><p>Next, you can create the file app.component.html as follows,</p><p><strong>src/app/app.component.html</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ffe6d744e7f1724dd34bd0d56eff29ec/href">https://medium.com/media/ffe6d744e7f1724dd34bd0d56eff29ec/href</a></iframe><p>In <strong>app.component.html </strong>we basically build template-driven form front-end means user view of the form. So as an outcome, you can have a Template-driven form by following above mentions steps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ouxDr76xBN0M4mjEj3H1A.png" /></figure><p>In angular, always the magic is happening in behind the seans, so any type we used above in &lt;form&gt; tag angular attaches at<strong>“ngForm” </strong>directive to the tag that gives the valuable information about the form.</p><p>The <strong>ngForm directive</strong> gives two important things, such as</p><ul><li>Form field values</li><li>Valid/Invalid status</li></ul><h3><strong>Reactive form</strong></h3><pre>C:\Users\user&gt; ng new ng-forms</pre><p>You can use the above Angular commands to create the new project, by this process it installing the dependencies such as Node.js, npm.</p><pre>C:\Users\user\ng-forms&gt; ng serve</pre><p>The above command flag opens up the browser automatically. This angular command gives the URL to open your project on the browser.</p><h4>As an example <strong>— </strong><a href="http://localhost:4200/"><strong>http://localhost:4200/</strong></a></h4><p>So, now we successfully create our first angular project.</p><p>okay then let’s move to our code editor and opens up the created project.</p><p>The first thing we need to do before we construct each other forms it needs to import the reactive <strong>form-Module</strong> into your <strong>app.module.ts</strong> file. Path to the app.module.ts<strong> </strong>file(src → app → app.module.ts)</p><p><strong>src/app/app.module.ts</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/834caf3e140eca07f1fb49009c022fc4/href">https://medium.com/media/834caf3e140eca07f1fb49009c022fc4/href</a></iframe><p>Then next we need to work with <strong><em>app.component.ts</em></strong> code first. We can start with import some necessary form, specific functions and component that need to perform.</p><p>In case we need to import three different class from the <strong><em>Angular Form Library. </em></strong>That is,</p><ul><li>FormBuilder</li><li>FormGroup</li><li>Validators</li></ul><p>Here you can define the different property as follows,</p><p><strong>src/app/app.component.ts</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cafde3654618d7cbf69ab847f9b99adc/href">https://medium.com/media/cafde3654618d7cbf69ab847f9b99adc/href</a></iframe><p>Before developing the<em> </em><strong><em>html component</em></strong><em> </em>file you need to import the front-end frame-work code foundation which is really quick easy for structuring and setting-up form. So you can copy and paste the CSS/ bootstrap link here as follows that quick easy for use.</p><p><strong>src/index.html</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc32725d08fc83c6673f7517f87e10ff/href">https://medium.com/media/dc32725d08fc83c6673f7517f87e10ff/href</a></iframe><p>Okay, now we can move to the template and let’s start to define the html for our reactive form.</p><p><strong>src/app/app.component.html</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/76f7d471ac248cdddfb4f5c02ca2e34e/href">https://medium.com/media/76f7d471ac248cdddfb4f5c02ca2e34e/href</a></iframe><p>The next simply you can add to the few line into css for change the background body of the form.</p><p><strong>src/styles.css</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0ccaa9cd4eb7a4a987e8f492b3946cb1/href">https://medium.com/media/0ccaa9cd4eb7a4a987e8f492b3946cb1/href</a></iframe><p>After that, you can implement the following code section into your <strong><em>app.component.css</em></strong> file that gives goof look for your UI of form.</p><p><strong>src/app/app.component.css</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f7bc4698a9eb2299e2468b99218a5816/href">https://medium.com/media/f7bc4698a9eb2299e2468b99218a5816/href</a></iframe><p>So finally you can create a reactive form by following mentions steps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hnDw-2cFr4SvwMBB9Z4gZg.png" /></figure><p>So I hope now you have a better idea about areas that need to develop the both reactive from and template-driven form.</p><p>ENJOY YOUR CODING!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a72a8651a07" width="1" height="1" alt=""><hr><p><a href="https://medium.com/enz-a/angular-forms-guide-ii-how-to-develop-the-basic-reactive-template-driven-forms-9a72a8651a07">Angular Forms Guide II — How to develop the basic Reactive &amp; Template-driven Forms</a> was originally published in <a href="https://medium.com/enz-a">Enz-a</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DevTools]]></title>
            <link>https://medium.com/enz-a/devtools-4a7d7e1203e0?source=rss----2e4167b052fe---4</link>
            <guid isPermaLink="false">https://medium.com/p/4a7d7e1203e0</guid>
            <dc:creator><![CDATA[Nadeesha Dilrukshi]]></dc:creator>
            <pubDate>Mon, 25 Jan 2021 21:22:43 GMT</pubDate>
            <atom:updated>2021-01-26T04:12:12.048Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*ANvs_mywf85UUu6XJsH7Ew.png" /></figure><p><strong>What is DevTools?</strong></p><p>“DevTools is a set of web developer tools built directly into the browser which helps developers to edit pages on-the-fly and diagnose problems quickly, which ultimately helps you build better websites, faster.”</p><p>They are a set of tools which gives you the possibility to modify, test or see how your code works.</p><p>Every modern web browser includes a powerful suite of developer tools. These tools have the capability to perform the range of things, from inspecting currently-loaded HTML, CSS and JavaScript to showing which assets the page has requested and how long they took to load.</p><p>Every browser has a set of tools but there are slight differences among them. In this reason, we are going to focus on Google Chrome. In this browser, these tools are called DevTools. This article explains various basic functions that consist of your browser’s DevTools.</p><h4>How to Open DevTools</h4><p>There are many ways to open DevTools because different users want quick access to different parts of the DevTools UI.</p><ol><li>First of all, you have to go to the menu, then select “More tools” and finally “Developer Tools”.</li></ol><ul><li>When we work with the DOM or CSS, you can simply <strong><em>right-click </em></strong>an element on the page and select <strong><em>Inspect </em></strong>to jump into the <strong><em>Element </em></strong>panel. <strong>OR </strong>you can press the following commands,</li></ul><p>“C<strong><em>ommand + Option + C” → </em></strong>(Mac)<strong><em> </em></strong>or “<strong><em>Control + Shift + C” →</em></strong>(Windows, Linux, Chrome OS).</p><ul><li>When you want to see logged messages or run JavaScript, press Command+Option+J (Mac) or Control+Shift+J (Windows, Linux, Chrome OS) to jump straight into the <strong>Console</strong> panel.</li></ul><h4>Inspect a node</h4><p>You can simply open the particular node, by selecting the “StackOverflow”. <strong>Inspect</strong> is a fast way to open DevTools and investigate that node.</p><ol><li>Right-click <strong>StackOverflow</strong> below and select <strong>Inspect</strong>.</li></ol><figure><img alt="hshsh" src="https://cdn-images-1.medium.com/max/1024/1*y6vPA_ZyrYu26BugL8UjOg.png" /><figcaption><strong>Figure 1. Inspecting a node</strong></figcaption></figure><p>Next, click the <strong>Inspect </strong>icon in the top-left corner of DevTools.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/26/0*uofssIgGRMFo6mCC.png" /><figcaption><strong>Inspect Icon</strong></figcaption></figure><p>This icon helps to view the part or full of the code which we go through the UI. Inspecting a node is also the first step towards viewing and changing a node’s styles. As the following figure illustrate you click the inspection icon for certain functions. Here you can find out some missing part which is impossible to view through the exact code sections because usually everyone knew that project or part of the code what we developed is comprises with thousands of code lines. So DevTools become more essential in this point view which makes complex, unnoticeable task correct by simply touching.</p><p>Likewise using DevTools a user can do the follows such as,</p><ul><li>Navigate the DOM Tree with a keyboard to inspect the certain node need to navigate</li><li>Can search for the node</li><li>To edit the content</li><li>To edit attributes</li><li>Edit node type</li><li>Can hide a node</li><li>Can do CSS functionalities etc.</li></ul><p>let’s briefly describe some main tools of this consent.</p><h3>Test Your Responsive Design</h3><p>The Toggle device mood is don’t mainly focused on new users. It is in the corner of Right-side by clicking the Toggle Device mood you can have access to manage the Device moods into the given moods as your preference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*qb-A7coUNsaiufwrIoWy8A.png" /><figcaption><strong>Figure 2. Toggle Device mode</strong></figcaption></figure><p>You can ensure the responsive with Google’s mobile-friendly update AKA Mobilegeddon still the zeitgeist, this is super important that can check ensure the responsive of your web site.</p><p>Chrome DevTools emulate mobile devices, enabling you to experience mobile users journey on almost any mobile device, without having to physically have one with you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b7gks3eR0y9S-R09UnndLA.png" /><figcaption><strong>Figure 3. Select the Toggle Device mode</strong></figcaption></figure><p><strong>once you opened it, you can find the basic 8 parts to inspect the website:</strong></p><h4><strong>Element Panel</strong></h4><p>Using element panel you can inspect and edit the code in real-time for both CSS and the HTML. But consider your changes are will not be saved at the time once you upgrade or leave the website then code will return to its original. For example, you can change the name of the class of your code, add a new attribute or even can modify the value of it.</p><p>Basically using the element panel you can view and change the DOM and CSS. in addition to that you can <em>Edit styles, edit the DOM, Inspect animation and especially can find out the unused CSS.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5gM2nVdmvjJuCoLxoQ4Vcw.png" /><figcaption><strong>Figure 4. Element Panel</strong></figcaption></figure><h4>Console panel</h4><p>Consol provides two functions when you able to testing web pages.</p><ul><li>First one is logging diagnostic information in the development process.</li><li>The second one, as a shell to interact with JavaScript code.</li></ul><p>View messages and run JavaScript from the Console. Here you can simply run do the consol tasks. These DevTools consols are Java-based console, which can execute simple algorithms and function. So you consol able to revel the errors sometimes even which is not discovered. Therefore using the DevTools it is easy to catch the errors during the development stage. The important part of the console panel is it interact form command line and it has console API reference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iE_q-sRWE47b35ME.png" /><figcaption><strong>Figure 4. Console Panel</strong></figcaption></figure><h4>Sources panel</h4><p>Debug JavaScript, persist changes made in DevTools across page reloads, save and run snippets of JavaScript, and save changes that you make in DevTools to disk. Simply the source panel is debugging your JavaScript code in a fast and efficient way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vIL9viy0PbxrD_sn.png" /><figcaption><strong>Figure 5. Source Panel</strong></figcaption></figure><h4>Network panel</h4><p>View and debug network activity. such as this panel provides information about some resources that user required and able to download over the network in real-time. This is a good way to optimize your page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dfOLP89bzJUS6BKc.png" /><figcaption><strong>Figure 5. Network Panel</strong></figcaption></figure><h4><strong>Timeline</strong></h4><p>This offers an overview of the time that is spent when loading and using your web site.</p><h4><strong>Profile</strong></h4><p>Using profile panel you can optimize the code and understand resources are being spent.</p><h4><strong>Application</strong></h4><p>It is can inspect all resources.</p><h4><strong>Security</strong></h4><p>The type of the panel in DevTools that able to debug problems with your certificate.</p><p>All of these parts are useful for several reasons and, when you able to work with them you won’t able to work without them. Let’s discuss the benefit for Development tools from two points of view:</p><ul><li>when you used these tools to inspect the code of your developing project, you will able to catch the mistakes or bugs immediately and then you can also able to fire the solution in real-time without deleting your own code. Thus, the most important benefit is that you can check the time takes to load your web and which elements are the most delayed. Likewise, you can monitor how long it takes an improve the performance of the web by eliminating these type of problems.</li><li>Second, one is that you can open Devtools to see the webs that are not actually yours. In case this really practical if you interest to learn about how they make the specific part of their web and if you need to do some development task in your but you don’t have the knowledge to develop it. so when we face this type of situation the devtools is the best solution.</li></ul><p>So this the basic parts of the DevTools, by this article you can have basic knowledge about the DevTools and importance and benefit of those tools.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a7d7e1203e0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/enz-a/devtools-4a7d7e1203e0">DevTools</a> was originally published in <a href="https://medium.com/enz-a">Enz-a</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular Forms Guide — Reactive Forms Vs. Template-driven Form]]></title>
            <link>https://medium.com/enz-a/angular-forms-guide-reactive-forms-vs-template-driven-form-32abdb1b7c5?source=rss----2e4167b052fe---4</link>
            <guid isPermaLink="false">https://medium.com/p/32abdb1b7c5</guid>
            <dc:creator><![CDATA[Nadeesha Dilrukshi]]></dc:creator>
            <pubDate>Tue, 19 Jan 2021 13:04:06 GMT</pubDate>
            <atom:updated>2021-01-25T03:26:18.838Z</atom:updated>
            <content:encoded><![CDATA[<h3>Angular Forms Guide — Reactive Forms Vs. Template-driven Form</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t0KzRXq5qo8OBZh-9ePmaQ.png" /></figure><blockquote>This blog is about the fundamental comparison between two different alternatives for building forms in Angular. Reactive Form Vs. Template-driven Forms. we will go through the following topics:</blockquote><ul><li>Template-driven Forms</li><li>Reactive Forms</li><li>Reactive Forms comprised of Template-driven Forms</li><li>Key differences</li><li>summary</li></ul><h3>Angular Template-driven Forms</h3><p>This is the form type basically based on the Template-driven method. Template-driven forms are based only on the template-directive.</p><blockquote><em>Importantly template-driven forms</em> <strong>use two-way data binding </strong><em>to update the data model in the component as changes are made in the template and vise versa.</em></blockquote><p>Using the Angular Template you can build any kind of form such as <strong><em>login forms, contact forms, and pretty much any business form</em></strong>. therefore you can lay out the control creatively and bind them to the data in your object model. further, template-driven enable to specify the validation rules and display validation errors, conditional enable or disable specific controls, trigger built-in visual feedback, and much more.</p><p>This forms useful for adding a simple form to an app, <strong><em>as an example an email list signup form. </em></strong>But they have scale limitation, therefore, template-driven forms well fit for the form which has very basic form requirements and logic which can manage using the template.</p><p>Template-driven forms: <strong>Features,</strong></p><ul><li>Easy to use</li><li>Template-driven forms are simple and straight forward</li><li>All the validations, forms elements are all defined in the template file</li><li>Forms are tracked automatically</li><li>Tracked forms data traverses via various states (pristine etc)</li><li>Uses Two-Way Data Binding techniques to bind data</li><li>Most of the code resides in the template file</li><li>Validations are mostly the default HTML5 validations</li><li>Minimal component code as most of the code is in the template file</li><li>Unit testing will be a challenge</li></ul><p><strong>Creating Template-driven Form</strong>,</p><p><strong>Build the form</strong></p><p>The provided sample application creates the Hero the class which defines the data model reflected in the form.</p><p><strong>src/app/hero.ts</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*kBW-tHnSXks6cfIxPbKZlQ.png" /></figure><p>The form layout and details are defined in the HeroFormComponent class.</p><p><strong>src/app/hero-form/hero-form.component.ts (v1)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*wUDayGrhg2HVYsRTzPxa5w.png" /></figure><p>The following code creates a new hero instance so that the initial form can show an example of hero.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*vk37tEn_eHWFUnavZCJXtw.png" /></figure><p>The application enables the Forms feature and registers the created form component.</p><p><strong>src/app/app.module.ts</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*MYdiLk-W4_akB0s-vHYMsg.png" /></figure><p>Next, the form is displayed in the application layout defined by the root component’s template.</p><p><strong>src/app/app.component.html</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*xKszJNx-mhN0YAUyrwdMtw.png" /></figure><p>The sample form uses some style classes and to use these styles, the app’s style sheet imports the library.</p><p><strong>src/styles.css</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*bkvLAWq4pRYw1wZ9VnbHIg.png" /></figure><p><strong>src/app/hero-form/hero-form.component.html (powers)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*QYPsAA9_mQ_Rm_d9DU7Kbw.png" /></figure><p>above code, sections help to simply build the template-driven forms.</p><h3><strong>Angular Reactive Forms</strong></h3><p>Reactive forms provide a module-driven approach basically handling form inputs whose values change over time. It also refers to as “Dynamic forms” or “Module-driven forms”.</p><p>Reactive forms might seem complicated but they can be very useful when you actually get it. They are really powerful and flexible.</p><p>Reactive forms provide direct, explicit access to the underlying forms object model. such as it capable of managing the state of a form at a given point in time with maintains the integrity of the model between changes. further reactive forms are constructed around observable streams, where form values and input are provided as streams of input values, that can be accessed synchronously.</p><p>In addition, reactive forms provide a straightforward path the testing and any consumers of the streams have access too manipulate that data more safely.</p><p>With Reactive forms, all the declaration and structuring of the forms is to be done in the code such as TypeScript file (TS file) This model is then used in template (HTML).</p><p><em>“Reactive forms provide a model-driven approach to handling form inputs whose values change over time.”</em></p><p>Reactive forms: <strong>Features,</strong></p><ul><li>Using <a href="https://www.digitalocean.com/community/tutorials/angular-reactive-forms-custom-validator">custom validators</a></li><li>Changing validation dynamically</li><li>Dynamically adding form fields</li></ul><p><strong>Creating Reactive Forms in Angular</strong>,</p><p>In angular reactive form module, the component class is the main source of truth, therefore the validation functions are included in the form control model of the component class. In this way, angular can call these validators anytime there is a change in the value of the form control.</p><p>To add reactive capabilities to the email field, inside the <em>app.module.ts</em> file, let’s import ReactiveFormsModule from the @angular/forms package and specify it in the imports array.</p><p>Here is the code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*6ET6uC2YvVJgtoJ3EH-Hww.png" /></figure><p>With reactive forms, the logic is declared entirely in the component class, so the template syntax is made very easy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*EjLchLj1kcOnBrMza0S87Q.png" /></figure><p>And now in the component class, we define our form group and individual form controls within our form group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*hVGimfyEJZGoh_UTV3d-_A.png" /></figure><p><strong>Form Builder</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*3L8BcChzV3t2i31mRjDoRA.png" /></figure><p><strong>Validation</strong></p><p>In angular adding validation to the forms is a simple task. Just by adding the <strong>Validators</strong> class to your imports and declare your form controls with arrays instead of simple string values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*_aslu2ojEDckTEi-H5V36g.png" /></figure><h3>Reactive Forms comprised of Template-driven Forms</h3><ul><li>Template-driven Forms use the FormsModule, while Reactive forms use the ReactiveFormsModule.</li><li>Template-driven forms based only on template directives, but Reactive forms are defined programmatically at the level of the component class.</li><li>Reactive Forms are more powerful as they are and easier to use, therefore, forms are a better <strong><em>default choice for new applications</em></strong>.</li><li>The Template Driven approach is very familiar to AngularJs developers.</li><li>The Reactive approachable to removes validation logic from the template, keeping the templates cleaner.</li><li>Compared to template-driven forms, reactive forms more robust: they’re more scalable, reusable, and testable.</li><li>Template-driven forms are suitable for small or simple forms, whereas reactive forms are more scalable and suitable for complex forms.</li><li>Reactive forms are easier to use in general and support better more advanced use cases via its Observable-based API.</li></ul><h3>Key differences</h3><p>The following table consists of the key differences between reactive and template-driven forms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*5gAW7d6Rdkfy4syEltLGXg.png" /></figure><h3>Summary</h3><p>Template-driven Forms, as the ngModel supports bidirectional data binding, just like the AngularJs ng-model directive. Therefore in case Tamplate-driven Forms usable.</p><p>But other than that, Reactive Forms are a much better choice because they are more powerful, easier to use and encourage a better separation between the view and business logic.</p><p>For these reasons, Reactive Forms tend to work better than Template Driven forms, and they are the better default choice for new applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*DMCWaD_mIoT64-py_94qAg.png" /></figure><p>In case that you want to learn Angular Forms in detail (both reactive and template-driven), you can check the<strong> </strong><a href="https://angular.io/guide/reactive-forms"><strong>Reactive forms</strong></a><strong> </strong>and <a href="https://angular.io/guide/forms#building-a-template-driven-form"><strong>Building a template-driven form</strong></a><strong>.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32abdb1b7c5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/enz-a/angular-forms-guide-reactive-forms-vs-template-driven-form-32abdb1b7c5">Angular Forms Guide — Reactive Forms Vs. Template-driven Form</a> was originally published in <a href="https://medium.com/enz-a">Enz-a</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>