<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
>

<channel>
	<title>form - Bipon's Diary</title>
	<atom:link href="https://biponnotes.iglyphic.com/tag/form/feed/" rel="self" type="application/rss+xml" />
	<link>https://biponnotes.iglyphic.com</link>
	<description>Do good for others. It will come back in unexpected ways.</description>
	<lastBuildDate>Wed, 08 Jan 2020 12:21:05 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.9.10</generator>
<site xmlns="com-wordpress:feed-additions:1">168324471</site>	<item>
		<title>Diving Deeper into Reactive Forms</title>
		<link>https://biponnotes.iglyphic.com/diving-deeper-into-reactive-forms/</link>
					<comments>https://biponnotes.iglyphic.com/diving-deeper-into-reactive-forms/#respond</comments>
		
		<dc:creator><![CDATA[bipon68]]></dc:creator>
		<pubDate>Wed, 08 Jan 2020 12:11:16 +0000</pubDate>
				<category><![CDATA[Angular Form]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[reactive]]></category>
		<guid isPermaLink="false">https://bipon.me/?p=323</guid>

					<description><![CDATA[<p>Step 1: create-session.component.html initial setup Step 2: create-session.component.ts initial setup Step 3: updated create-session.component.html file Step 4: create-session.component.ts Step 5: create-session.component.html again update for validation</p>
<p>The post <a href="https://biponnotes.iglyphic.com/diving-deeper-into-reactive-forms/">Diving Deeper into Reactive Forms</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Step 1: create-session.component.html  initial setup </p>



<pre class="wp-block-code"><code>&lt;div class="col-md-12">
    &lt;h3>Create Session&lt;/h3>
  &lt;/div>
  &lt;div class="col-md-6">
    &lt;form [formGroup]="newSessionForm" (ngSubmit)="saveSession(newSessionForm.value)" autocomplete="off">
      &lt;div class="form-group">
        &lt;label for="sessionName">Session Name:&lt;/label>
        &lt;input id="sessionName" type="text" class="form-control" placeholder="session name..." />
      &lt;/div>
      &lt;div class="form-group">
        &lt;label for="eventDate">Presenter:&lt;/label>
        &lt;input id="presenter" type="text" class="form-control" placeholder="presenter..." />
      &lt;/div>
      &lt;div class="form-group">
        &lt;label for="duration">Duration:&lt;/label>
        &lt;select class="form-control">
          &lt;option value="">select duration...&lt;/option>
          &lt;option value="1">Half Hour&lt;/option>
          &lt;option value="2">1 Hour&lt;/option>
          &lt;option value="3">Half Day&lt;/option>
          &lt;option value="4">Full Day&lt;/option>
        &lt;/select>
      &lt;/div>
      &lt;div class="form-group">
        &lt;label for="level">Level:&lt;/label>
        &lt;select class="form-control">
          &lt;option value="">select level...&lt;/option>
          &lt;option value="Beginner">Beginner&lt;/option>
          &lt;option value="Intermediate">Intermediate&lt;/option>
          &lt;option value="Advanced">Advanced&lt;/option>
        &lt;/select>
      &lt;/div>
      &lt;div class="form-group">
        &lt;label for="abstract">Abstract:&lt;/label>
        &lt;textarea id="abstract" rows=3 class="form-control" placeholder="abstract...">&lt;/textarea>
      &lt;/div>
      &lt;button type="submit" class="btn btn-primary mr-5">Save&lt;/button>
      &lt;button type="button" class="btn btn-default">Cancel&lt;/button>
    &lt;/form>
  &lt;/div></code></pre>



<p> Step 2: create-session.component.ts initial setup</p>



<pre class="wp-block-code"><code>import { FormControl, FormGroup, Validators } from '@angular/forms';
import { Component, OnInit } from '@angular/core';

@Component({
    templateUrl: './create-session.component.html'
})


export class createSessionComponent implements OnInit{

    newSessionForm: FormGroup
    name:FormControl
    presenter: FormControl
    duration:FormControl
    level:FormControl
    abstract:FormControl

    constructor(){}

    ngOnInit(){

        this.name = new FormControl('', Validators.required)
        this.presenter = new FormControl('', Validators.required)
        this.duration = new FormControl('', Validators.required)
        this.level = new FormControl('', Validators.required)
        this.abstract = new FormControl('', [Validators.required, Validators.maxLength(400)])

        this.newSessionForm = new FormGroup({
            name: this.name,
            presenter: this.presenter,
            duration: this.duration,
            level: this.level,
            abstract: this.abstract
        })
    }

    saveSession(formValues){
        console.log(formValues)
    }

}</code></pre>



<p> Step 3:  updated create-session.component.html file</p>



<pre class="wp-block-code"><code>&lt;div class="col-md-12">
    &lt;h3>Create Session&lt;/h3>
  &lt;/div>
  &lt;div class="col-md-6">
    &lt;form [formGroup]="newSessionForm" (ngSubmit)="saveSession(newSessionForm.value)" autocomplete="off">
      &lt;div class="form-group">
        &lt;label for="sessionName">Session Name:&lt;/label>
        &lt;input formControlName="name" id="sessionName" type="text" class="form-control" placeholder="session name..." />
      &lt;/div>
      &lt;div class="form-group">
        &lt;label for="eventDate">Presenter:&lt;/label>
        &lt;input id="presenter" type="text" class="form-control" placeholder="presenter..." />
      &lt;/div>
      &lt;div class="form-group">
        &lt;label for="duration">Duration:&lt;/label>
        &lt;select formControlName="duration" class="form-control">
          &lt;option value="">select duration...&lt;/option>
          &lt;option value="1">Half Hour&lt;/option>
          &lt;option value="2">1 Hour&lt;/option>
          &lt;option value="3">Half Day&lt;/option>
          &lt;option value="4">Full Day&lt;/option>
        &lt;/select>
      &lt;/div>
      &lt;div class="form-group">
        &lt;label for="level">Level:&lt;/label>
        &lt;select formControlName="level" class="form-control">
          &lt;option value="">select level...&lt;/option>
          &lt;option value="Beginner">Beginner&lt;/option>
          &lt;option value="Intermediate">Intermediate&lt;/option>
          &lt;option value="Advanced">Advanced&lt;/option>
        &lt;/select>
      &lt;/div>
      &lt;div class="form-group">
        &lt;label for="abstract">Abstract:&lt;/label>
        &lt;textarea formControlName="abstract" id="abstract" rows=3 class="form-control" placeholder="abstract...">&lt;/textarea>
      &lt;/div>
      &lt;button type="submit" class="btn btn-primary mr-5">Save&lt;/button>
      &lt;button type="button" class="btn btn-default">Cancel&lt;/button>
    &lt;/form>
  &lt;/div></code></pre>



<p>  Step 4:  create-session.component.ts</p>



<pre class="wp-block-code"><code>import { ISession } from './../shared/event.model';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { Component, OnInit } from '@angular/core';

@Component({
    templateUrl: './create-session.component.html',
    styles: [`
    em {float:right; color:#E05C65; padding-left: 10px;}
    .error input {background-color:#E3C3C5;}
    .error ::-webkit-input-placeholder { color: #999; }
    .error ::-moz-placeholder { color: #999; }
    .error :-moz-placeholder { color:#999; }
    .error :ms-input-placeholder { color: #999; }
  `]
})


export class createSessionComponent implements OnInit{

    newSessionForm: FormGroup
    name:FormControl
    presenter: FormControl
    duration:FormControl
    level:FormControl
    abstract:FormControl

    constructor(){}

    ngOnInit(){

        this.name = new FormControl('', Validators.required)
        this.presenter = new FormControl('', Validators.required)
        this.duration = new FormControl('', Validators.required)
        this.level = new FormControl('', Validators.required)
        this.abstract = new FormControl('', [Validators.required, Validators.maxLength(400)])

        this.newSessionForm = new FormGroup({
            name: this.name,
            presenter: this.presenter,
            duration: this.duration,
            level: this.level,
            abstract: this.abstract
        })
    }

    saveSession(formValues){
        // console.log(formValues)
        let session:ISession = {
            id: undefined,
            name: formValues.name,
            presenter:formValues.presenter,
            duration: +formValues.duration,
            level:formValues.lebel,            
            abstract:formValues.abstract,
            voters: []
        }
        console.log(session)
    }

}</code></pre>



<p>Step 5: create-session.component.html again update for validation</p>



<pre class="wp-block-code"><code>&lt;div class="col-md-12">
    &lt;h3>Create Session&lt;/h3>
  &lt;/div>
  &lt;div class="col-md-6">
    &lt;form [formGroup]="newSessionForm" (ngSubmit)="saveSession(newSessionForm.value)" autocomplete="off">
      &lt;div class="form-group" [ngClass]="{'error': name.invalid &amp;&amp; name.dirty}">
        &lt;label for="sessionName">Session Name:&lt;/label>
        &lt;em *ngIf="name.invalid &amp;&amp; name.dirty">Required&lt;/em>
        &lt;input formControlName="name" id="sessionName" type="text" class="form-control" placeholder="session name..." />
      &lt;/div>
      &lt;div class="form-group" [ngClass]="{'error': presenter.invalid &amp;&amp; presenter.dirty}">
        &lt;label for="eventDate">Presenter:&lt;/label>
        &lt;em *ngIf="presenter.invalid &amp;&amp; presenter.dirty">Required&lt;/em>
        &lt;input formControlName="presenter" id="presenter" type="text" class="form-control" placeholder="presenter..." />
      &lt;/div>
      &lt;div class="form-group" [ngClass]="{'error': duration.invalid &amp;&amp; duration.dirty}">
        &lt;label for="duration">Duration:&lt;/label>
        &lt;em *ngIf="duration.invalid &amp;&amp; duration.dirty">Required&lt;/em>
        &lt;select formControlName="duration" class="form-control">
          &lt;option value="">select duration...&lt;/option>
          &lt;option value="1">Half Hour&lt;/option>
          &lt;option value="2">1 Hour&lt;/option>
          &lt;option value="3">Half Day&lt;/option>
          &lt;option value="4">Full Day&lt;/option>
        &lt;/select>
      &lt;/div>
      &lt;div class="form-group" [ngClass]="{'error': level.invalid &amp;&amp; level.dirty}">
        &lt;label for="level">Level:&lt;/label>
        &lt;em *ngIf="level.invalid &amp;&amp; level.dirty">Required&lt;/em>
        &lt;select formControlName="level" class="form-control">
          &lt;option value="">select level...&lt;/option>
          &lt;option value="Beginner">Beginner&lt;/option>
          &lt;option value="Intermediate">Intermediate&lt;/option>
          &lt;option value="Advanced">Advanced&lt;/option>
        &lt;/select>
      &lt;/div>
      &lt;div class="form-group" [ngClass]="{'error': abstract.invalid &amp;&amp; abstract.dirty}">
        &lt;label for="abstract">Abstract:&lt;/label>
        &lt;em *ngIf="abstract.invalid &amp;&amp; abstract.dirty &amp;&amp; abstract?.errors.required">Required&lt;/em>
        &lt;em *ngIf="abstract.invalid &amp;&amp; abstract.dirty &amp;&amp; abstract?.errors.maxlength">Cannot exceed 400 character&lt;/em>
        &lt;textarea formControlName="abstract" id="abstract" rows=3 class="form-control" placeholder="abstract...">&lt;/textarea>
      &lt;/div>
      &lt;button [disabled]="newSessionForm.invalid" type="submit" class="btn btn-primary mr-5">Save&lt;/button>
      &lt;button type="button" class="btn btn-default">Cancel&lt;/button>
    &lt;/form>
  &lt;/div></code></pre><p>The post <a href="https://biponnotes.iglyphic.com/diving-deeper-into-reactive-forms/">Diving Deeper into Reactive Forms</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://biponnotes.iglyphic.com/diving-deeper-into-reactive-forms/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">323</post-id>	</item>
		<item>
		<title>Diving Deeper into Template Based Forms</title>
		<link>https://biponnotes.iglyphic.com/diving-deeper-template-based-forms/</link>
					<comments>https://biponnotes.iglyphic.com/diving-deeper-template-based-forms/#respond</comments>
		
		<dc:creator><![CDATA[bipon68]]></dc:creator>
		<pubDate>Wed, 08 Jan 2020 10:28:26 +0000</pubDate>
				<category><![CDATA[Angular Form]]></category>
		<category><![CDATA[binding]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[Two Way Binding]]></category>
		<guid isPermaLink="false">https://bipon.me/?p=321</guid>

					<description><![CDATA[<p>Step 1: create-event.component.html (Initially) Step 2: event.service.ts Step 3: create-event.component.ts Step 4: create-event.component.html app.module.ts</p>
<p>The post <a href="https://biponnotes.iglyphic.com/diving-deeper-template-based-forms/">Diving Deeper into Template Based Forms</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Step 1: create-event.component.html (Initially)</p>



<pre class="wp-block-code"><code>&lt;h1>New Event&lt;/h1>
&lt;hr>
&lt;div class="col-md-6">
  &lt;form #newEventForm="ngForm" (ngSubmit)="saveEvent(newEventForm.value)" autocomplete="off" novalidate>
    &lt;div class="form-group" [ngClass]="{'error': newEventForm.controls.name?.invalid &amp;&amp; newEventForm.controls.name?.touched}">
      &lt;label for="eventName">Event Name:&lt;/label>
      &lt;em *ngIf="newEventForm.controls.name?.invalid &amp;&amp; (newEventForm.controls.name?.touched)">Required&lt;/em>
      &lt;input (ngModel)="name" name="name" required id="name" type="text" class="form-control" placeholder="Name of your event..." />
    &lt;/div>
    &lt;div class="form-group" [ngClass]="{'error': newEventForm.controls.date?.invalid &amp;&amp; newEventForm.controls.date?.touched}">
      &lt;label for="eventDate">Event Date:&lt;/label>
      &lt;em *ngIf="newEventForm.controls.date?.invalid &amp;&amp; (newEventForm.controls.date?.touched)">Required&lt;/em>
      &lt;input (ngModel)="date" name="date" required id="eventDate" type="text" class="form-control" placeholder="format (mm/dd/yyyy)..." />
    &lt;/div>
    &lt;div class="form-group" [ngClass]="{'error': newEventForm.controls.time?.invalid &amp;&amp; newEventForm.controls.time?.touched}">
      &lt;label for="eventTime">Event Time:&lt;/label>
      &lt;em *ngIf="newEventForm.controls.time?.invalid &amp;&amp; (newEventForm.controls.time?.touched)">Required&lt;/em>
      &lt;input (ngModel)="time" name="time" required id="eventTime" type="text" class="form-control" placeholder="start and end time..." />
    &lt;/div>
    &lt;div class="form-group" [ngClass]="{'error': newEventForm.controls.price?.invalid &amp;&amp; newEventForm.controls.price?.touched}">
      &lt;label for="eventPrice">Event Price:&lt;/label>
      &lt;em *ngIf="newEventForm.controls.price?.invalid &amp;&amp; (newEventForm.controls.price?.touched)">Required&lt;/em>
      &lt;input (ngModel)="price" name="price" required id="eventPrice" type="text" type="number" class="form-control" placeholder="event price..." />
    &lt;/div>
    
    &lt;div class="form-group">
      &lt;label for="address">Event Location:&lt;/label>
      &lt;input (ngModel)="address" name="address" id="address" type="text" class="form-control" placeholder="Address of event..." />
    &lt;/div>
    &lt;div class="row">
      &lt;div class="col-md-6">
        &lt;input (ngModel)="city" name="city" id="city" type="text" class="form-control" placeholder="City..." />
      &lt;/div>
      &lt;div class="col-md-6" >
        &lt;input (ngModel)="country" name="country" id="country" type="text" class="form-control" placeholder="Country..." />
      &lt;/div>
    &lt;/div>

    &lt;div class="form-group">
      &lt;label for="onlineUrl">Online Url:&lt;/label>
      &lt;input (ngModel)="onlineUrl" name="onlineUrl" id="onlineUrl" type="text" class="form-control" placeholder="Online Url..." />
    &lt;/div>
    &lt;div class="form-group" [ngClass]="{'error': newEventForm.controls.imageUrl?.invalid &amp;&amp; newEventForm.controls.imageUrl?.touched}">
      &lt;label for="imageUrl">Image:&lt;/label>
      &lt;em *ngIf="newEventForm.controls.imageUrl?.invalid &amp;&amp; newEventForm.controls.imageUrl?.touched &amp;&amp; newEventForm.controls.imageUrl?.errors.required">Required&lt;/em>
      &lt;em *ngIf="newEventForm.controls.imageUrl?.invalid &amp;&amp; newEventForm.controls.imageUrl?.touched  &amp;&amp; newEventForm.controls.imageUrl?.errors.pattern">Must be a png or jpg url&lt;/em>
      &lt;input (ngModel)="imageUrl" name="imageUrl" required pattern=".*\/.*.(png|jpg)" id="imageUrl" type="text" class="form-control" placeholder="url of image..." />
      &lt;img />
    &lt;/div>
    
    &lt;button type="submit" class="btn btn-primary">Save&lt;/button>
    &lt;button type="button" [disabled]="newEventForm.invalid" class="btn btn-default" (click)="cancel()">Cancel&lt;/button>
  &lt;/form>
&lt;/div></code></pre>



<p>Step 2: event.service.ts</p>



<pre class="wp-block-code"><code>import { IEvent } from './event.model';
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs'

@Injectable()
export class EventService{
    getEvents(){
      let subject = new Subject()
      setTimeout(() => {
        subject.next(EVENTS); 
        subject.complete();}, 
        100)
        return subject;
    }

    getEvent(id:number):IEvent{
      return EVENTS.find(event => event.id === id)
    }
    saveEvent(event){
      event.id = 999
      event.session = []
      EVENTS.push(event)
    }
}

const EVENTS:IEvent[] = [
    {
      id: 1,
      name: 'Angular Connect',
      date: new Date('9/26/2036'),
      time: '10:00 am',
      price: 599.99,
      imageUrl: '/assets/images/angularconnect-shield.png',
      onlineUrl: 'http://google.com',
      sessions: [
        {
          id: 1,
          name: "Using Angular 4 Pipes",
          presenter: "Peter Bacon Darwin",
          duration: 1,
          level: "Intermediate",
          abstract: `Learn all about the new pipes in Angular 4, both 
          how to write them, and how to get the new AI CLI to write 
          them for you. Given by the famous PBD, president of Angular 
          University (formerly Oxford University)`,
          voters: ['bradgreen', 'igorminar', 'martinfowler']
        },
        {
          id: 2,
          name: "Getting the most out of your dev team",
          presenter: "Jeff Cross",
          duration: 1,
          level: "Intermediate",
          abstract: `We all know that our dev teams work hard, but with 
          the right management they can be even more productive, without 
          overworking them. In this session I'll show you how to get the 
          best results from the talent you already have on staff.`,
          voters: ['johnpapa', 'bradgreen', 'igorminar', 'martinfowler']
        },
        {
          id: 3,
          name: "Angular 4 Performance Metrics",
          presenter: "Rob Wormald",
          duration: 2,
          level: "Advanced",
          abstract: `Angular 4 Performance is hot. In this session, we'll see 
          how Angular gets such great performance by preloading data on 
          your users devices before they even hit your site using the 
          new predictive algorithms and thought reading software 
          built into Angular 4.`,
          voters: []
        },
        {
          id: 4,
          name: "Angular 5 Look Ahead",
          presenter: "Brad Green",
          duration: 2,
          level: "Advanced",
          abstract: `Even though Angular 5 is still 6 years away, we all want 
          to know all about it so that we can spend endless hours in meetings 
          debating if we should use Angular 4 or not. This talk will look at 
          Angular 6 even though no code has yet been written for it. We'll 
          look at what it might do, and how to convince your manager to 
          hold off on any new apps until it's released`,
          voters: []
        },
        {
          id: 5,
          name: "Basics of Angular 4",
          presenter: "John Papa",
          duration: 2,
          level: "Beginner",
          abstract: `It's time to learn the basics of Angular 4. This talk 
          will give you everything you need to know about Angular 4 to 
          get started with it today and be building UI's for your self 
          driving cars and butler-bots in no time.`,
          voters: ['bradgreen', 'igorminar']
        }
      ]
    },
    {
      id: 2,
      name: 'ng-nl',
      date: new Date('4/15/2037'),
      time: '9:00 am',
      price: 950.00,
      imageUrl: '/assets/images/ng-nl.png',
      onlineUrl: 'http://google.com',
      location: {
        address: 'The NG-NL Convention Center &amp; Scuba Shop',
        city: 'Amsterdam',
        country: 'Netherlands'
      },
      sessions: [
        {
          id: 1,
          name: "Testing Angular 4 Workshop",
          presenter: "Pascal Precht &amp; Christoph Bergdorf",
          duration: 4,
          level: "Beginner",
          abstract: `In this 6 hour workshop you will learn not only how to test Angular 4, 
          you will also learn how to make the most of your team's efforts. Other topics
          will be convincing your manager that testing is a good idea, and using the new
          protractor tool for end to end testing.`,
          voters: ['bradgreen', 'igorminar']
        },
        {
          id: 2,
          name: "Angular 4 and Firebase",
          presenter: "David East",
          duration: 3,
          level: "Intermediate",
          abstract: `In this workshop, David East will show you how to use Angular with the new
          ultra-real-time 5D Firebase back end, hosting platform, and wine recommendation engine.`,
          voters: ['bradgreen', 'igorminar', 'johnpapa']
        },
        {
          id: 3,
          name: "Reading the Angular 4 Source",
          presenter: "Patrick Stapleton",
          duration: 2,
          level: "Intermediate",
          abstract: `Angular 4's source code may be over 25 million lines of code, but it's really 
          a lot easier to read and understand then you may think. Patrick Stapleton will talk
          about his secretes for keeping up with the changes, and navigating around the code.`,
          voters: ['martinfowler']
        },
        {
          id: 4,
          name: "Hail to the Lukas",
          presenter: "Lukas Ruebbelke",
          duration: 1,
          level: "Beginner",
          abstract: `In this session, Lukas will present the 
          secret to being awesome, and how he became the President 
          of the United States through his amazing programming skills, 
          showing how you too can be success with just attitude.`, 
          voters: ['bradgreen']
        },
      ]
    },
    {
      id: 3,
      name: 'ng-conf 2037',
      date: new Date('5/4/2037'),
      time: '10:00 am',
      price: 759.00,
      imageUrl: '/assets/images/ng-conf.png',
      location: {
        address: 'The Palatial America Hotel',
        city: 'Salt Lake City',
        country: 'USA'
      },
      sessions: [
        {
          id: 1,
          name: "How Elm Powers Angular 4",
          presenter: "Murphy Randle",
          duration: 2,
          level: "Intermediate",
          abstract: `We all know that Angular is written in Elm, but did you
          know how the source code is really written? In this exciting look
          into the internals of Angular 4, we'll see exactly how Elm powers
          the framework, and what you can do to take advantage of this knowledge.`,
          voters: ['bradgreen', 'martinfowler', 'igorminar']
        },
        {
          id: 2,
          name: "Angular and React together",
          presenter: "Jamison Dance",
          duration: 2,
          level: "Intermediate",
          abstract: `React v449.6 has just been released. Let's see how to use 
          this new version with Angular to create even more impressive applications.`,
          voters: ['bradgreen', 'martinfowler']
        },
        {
          id: 3,
          name: "Redux Woes",
          presenter: "Rob Wormald",
          duration: 1,
          level: "Intermediate",
          abstract: `Everyone is using Redux for everything from Angular to React to 
          Excel macros, but you're still having trouble grasping it? We'll take a look
          at how farmers use Redux when harvesting grain as a great introduction to 
          this game changing technology.`,
          voters: ['bradgreen', 'martinfowler', 'johnpapa']
        },
        {
          id: 4,
          name: "ng-wat again!!",
          presenter: "Shai Reznik",
          duration: 1,
          level: "Beginner",
          abstract: `Let's take a look at some of the stranger pieces of Angular 4,
          including neural net nets, Android in Androids, and using pipes with actual pipes.`,
          voters: ['bradgreen', 'martinfowler', 'igorminar', 'johnpapa']
        },
        {
          id: 5,
          name: "Dressed for Success",
          presenter: "Ward Bell",
          duration: 2,
          level: "Beginner",
          abstract: `Being a developer in 2037 is about more than just writing bug-free code. 
          You also have to look the part. In this amazing expose, Ward will talk you through
          how to pick out the right clothes to make your coworkers and boss not only
          respect you, but also want to be your buddy.`,
          voters: ['bradgreen', 'martinfowler']
        },
        {
          id: 6,
          name: "These aren't the directives you're looking for",
          presenter: "John Papa",
          duration: 2,
          level: "Intermediate",
          abstract: `Coinciding with the release of Star Wars Episode 18, this talk will show how
          to use directives in your Angular 4 development while drawing lessons from the new movie,
          featuring all your favorite characters like Han Solo's ghost and Darth Jar Jar.`,
          voters: ['bradgreen', 'martinfowler']
        },
      ]
    },
    {
      id: 4,
      name: 'UN Angular Summit',
      date: new Date('6/10/2037'),
      time: '8:00 am',
      price: 800.00,
      imageUrl: '/assets/images/basic-shield.png',
      location: {
        address: 'The UN Angular Center',
        city: 'New York',
        country: 'USA'
      },
      sessions: [
        {
          id: 1,
          name: "Diversity in Tech",
          presenter: "Sir Dave Smith",
          duration: 2,
          level: "Beginner",
          abstract: `Yes, we all work with cyborgs and androids and Martians, but 
          we probably don't realize that sometimes our internal biases can make it difficult for
          these well-designed coworkers to really feel at home coding alongside us. This talk will
          look at things we can do to recognize our biases and counteract them.`,
          voters: ['bradgreen', 'igorminar']
        },
        {
          id: 2,
          name: "World Peace and Angular",
          presenter: "US Secretary of State Zach Galifianakis",
          duration: 2,
          level: "Beginner",
          abstract: `Angular has been used in most of the major peace brokering that has
          happened in the last decade, but there is still much we can do to remove all
          war from the world, and Angular will be a key part of that effort.`,
          voters: ['bradgreen', 'igorminar', 'johnpapa']
        },
        {
          id: 3,
          name: "Using Angular with Androids",
          presenter: "Dan Wahlin",
          duration: 3,
          level: "Advanced",
          abstract: `Androids may do everything for us now, allowing us to spend all day playing 
          the latest Destiny DLC, but we can still improve the massages they give and the handmade
          brie they make using Angular 4. This session will show you how.`,
          voters: ['igorminar', 'johnpapa']
        },
      ]
    },
    {
      id: 5,
      name: 'ng-vegas',
      date: new Date('2/10/2037'),
      time: '9:00 am',
      price: 400.00,
      imageUrl: '/assets/images/ng-vegas.png',
      location: {
        address: 'The Excalibur',
        city: 'Las Vegas',
        country: 'USA'
      },
      sessions: [
        {
          id: 1,
          name: "Gambling with Angular",
          presenter: "John Papa",
          duration: 1,
          level: "Intermediate",
          abstract: `No, this talk isn't about slot machines. We all know that 
          Angular is used in most waiter-bots and coke vending machines, but
          did you know that was also used to write the core engine in the majority
          of voting machines? This talk will look at how all presidential elections
          are now determined by Angular code.`,
          voters: ['bradgreen', 'igorminar']
        },
        {
          id: 2,
          name: "Angular 4 in 60ish Minutes",
          presenter: "Dan Wahlin",
          duration: 2,
          level: "Beginner",
          abstract: `Get the skinny on Angular 4 for anyone new to this great new technology.
          Dan Wahlin will show you how you can get started with Angular in 60ish minutes, 
          guaranteed!`,
          voters: ['bradgreen', 'igorminar', 'johnpapa']
        }
      ]
    }
  ]</code></pre>



<p>Step 3: create-event.component.ts</p>



<pre class="wp-block-code"><code>import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { EventService } from '../shared/event.service';

@Component({
    templateUrl: './create-event.component.html',
    styles: [`
    em {float:right; color:#E05C65; padding-left: 10px;}
    .error input {background-color:#E3C3C5;}
    .error ::-webkit-input-placeholder { color: #999; }
    .error ::-moz-placeholder { color: #999; }
    .error :-moz-placeholder { color:#999; }
    .error :ms-input-placeholder { color: #999; }
  `]
})

export class CreateEventComponent implements OnInit{

    isDirty:boolean = true;
    newEvent
    event: any;

    constructor(private router: Router, private eventService: EventService){}

    ngOnInit(){
        this.event = {
            name: 'UI Event',
            date: '9/9/2020',
            time: '10am',
            price: 999.99,
            location: {
                address: '456 happy St',
                city: 'London',
                country: 'UK'
            },
            onlineUrl: 'http://google.com',
            imageUrl: 'http://google.com/cat.png'
        }
    }

    saveEvent(formValues){
        // console.log(formValues)
        this.eventService.saveEvent(formValues)
        this.isDirty = false
        this.router.navigate(['/events']);
    }

    cancel(){
        this.router.navigate(['/events']);
    }

}</code></pre>



<p>Step 4: create-event.component.html</p>



<pre class="wp-block-code"><code>&lt;h1>New Event&lt;/h1>
&lt;hr>
&lt;div class="col-md-6">
  &lt;form #newEventForm="ngForm" (ngSubmit)="saveEvent(newEventForm.value)" autocomplete="off" novalidate>
    &lt;div class="form-group" [ngClass]="{'error': newEventForm.controls.name?.invalid &amp;&amp; newEventForm.controls.name?.touched}">
      &lt;label for="eventName">Event Name:&lt;/label>
      &lt;em *ngIf="newEventForm.controls.name?.invalid &amp;&amp; (newEventForm.controls.name?.touched)">Required&lt;/em>
      &lt;input [(ngModel)]="event.name" name="name" required id="name" type="text" class="form-control" placeholder="Name of your event..." />
    &lt;/div>
    &lt;div class="form-group" [ngClass]="{'error': newEventForm.controls.date?.invalid &amp;&amp; newEventForm.controls.date?.touched}">
      &lt;label for="eventDate">Event Date:&lt;/label>
      &lt;em *ngIf="newEventForm.controls.date?.invalid &amp;&amp; (newEventForm.controls.date?.touched)">Required&lt;/em>
      &lt;input [(ngModel)]="event.date" name="date" required id="eventDate" type="text" class="form-control" placeholder="format (mm/dd/yyyy)..." />
    &lt;/div>
    &lt;div class="form-group" [ngClass]="{'error': newEventForm.controls.time?.invalid &amp;&amp; newEventForm.controls.time?.touched}">
      &lt;label for="eventTime">Event Time:&lt;/label>
      &lt;em *ngIf="newEventForm.controls.time?.invalid &amp;&amp; (newEventForm.controls.time?.touched)">Required&lt;/em>
      &lt;input [(ngModel)]="event.time" name="time" required id="eventTime" type="text" class="form-control" placeholder="start and end time..." />
    &lt;/div>
    &lt;div class="form-group" [ngClass]="{'error': newEventForm.controls.price?.invalid &amp;&amp; newEventForm.controls.price?.touched}">
      &lt;label for="eventPrice">Event Price:&lt;/label>
      &lt;em *ngIf="newEventForm.controls.price?.invalid &amp;&amp; (newEventForm.controls.price?.touched)">Required&lt;/em>
      &lt;input [(ngModel)]="event.price" name="price" required id="eventPrice" type="text" type="number" class="form-control" placeholder="event price..." />
    &lt;/div>

    &lt;div ngModelGroup="location">
        &lt;div class="form-group">
            &lt;label for="address">Event Location:&lt;/label>
            &lt;input [(ngModel)]="event.location.address" name="address" id="address" type="text" class="form-control" placeholder="Address of event..." />
          &lt;/div>
          &lt;div class="row">
            &lt;div class="col-md-6">
              &lt;input [(ngModel)]="event.location.city" name="city" id="city" type="text" class="form-control" placeholder="City..." />
            &lt;/div>
            &lt;div class="col-md-6" >
              &lt;input [(ngModel)]="event.location.country" name="country" id="country" type="text" class="form-control" placeholder="Country..." />
            &lt;/div>
          &lt;/div>
    &lt;/div>
    
    

    &lt;div class="form-group">
      &lt;label for="onlineUrl">Online Url:&lt;/label>
      &lt;input [(ngModel)]="event.onlineUrl" name="onlineUrl" id="onlineUrl" type="text" class="form-control" placeholder="Online Url..." />
    &lt;/div>
    &lt;div class="form-group" [ngClass]="{'error': newEventForm.controls.imageUrl?.invalid &amp;&amp; newEventForm.controls.imageUrl?.touched}">
      &lt;label for="imageUrl">Image:&lt;/label>
      &lt;em *ngIf="newEventForm.controls.imageUrl?.invalid &amp;&amp; newEventForm.controls.imageUrl?.touched &amp;&amp; newEventForm.controls.imageUrl?.errors.required">Required&lt;/em>
      &lt;em *ngIf="newEventForm.controls.imageUrl?.invalid &amp;&amp; newEventForm.controls.imageUrl?.touched  &amp;&amp; newEventForm.controls.imageUrl?.errors.pattern">Must be a png or jpg url&lt;/em>
      &lt;input [(ngModel)]="event.imageUrl" name="imageUrl" required pattern=".*\/.*.(png|jpg)" id="imageUrl" type="text" class="form-control" placeholder="url of image..." />
      &lt;img [src]="newEventForm.controls.imageUrl.value" *ngIf="newEventForm.controls.imageUrl?.value"/>
    &lt;/div>
    
    &lt;button type="submit" class="btn btn-primary mr-5">Save&lt;/button>
    &lt;button type="button" [disabled]="newEventForm.invalid" class="btn btn-default" (click)="cancel()">Cancel&lt;/button>
  &lt;/form>
&lt;/div></code></pre>



<p>app.module.ts</p>



<pre class="wp-block-code"><code>import { AuthService } from './user/auth.service';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { EventsAppComponent } from './events-app.component';
import { EventListComponent } from './events/event-list.component';
import { EventThumbnailComponent } from './events/event-thumbnail.component';
import { EventService } from './events/shared/event.service';
import { ToastrService } from './common/toastr.service';
import { EventDetailsComponent } from './events/event-details/event-details.component';
import { RouterModule } from '@angular/router';
import { appRoutes } from 'src/routes';
import { CreateEventComponent } from './events/event-details/create-event.component';
import { Error404Component } from './errors/404.component';
import { EventRouteActivator } from './events/event-details/event-route.activator.service';
import { EventListResolver } from './events/shared/events-list-resolver.service';
import { NavBarComponent } from './nav/nav-bar.component';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';

@NgModule({
  declarations: [
    EventsAppComponent,
    EventListComponent,
    EventThumbnailComponent,
    NavBarComponent,
    EventDetailsComponent,
    CreateEventComponent,
    Error404Component
  ],
  imports: [
    BrowserModule,
    FormsModule,
    ReactiveFormsModule,
    RouterModule.forRoot(appRoutes)
  ],
  providers: [
    EventService, 
    ToastrService, 
    EventRouteActivator,
    EventListResolver,
    AuthService,
      {
        provide:'canDeactivateCreateEvent',
        useValue: checkDirtyState
      }
  ],
  bootstrap: [EventsAppComponent]
})
export class AppModule { }

export function checkDirtyState(component: CreateEventComponent){
  if(component.isDirty)
    return window.confirm('You have not saved this event, do you really want to cancel?')
  return true
}
</code></pre><p>The post <a href="https://biponnotes.iglyphic.com/diving-deeper-template-based-forms/">Diving Deeper into Template Based Forms</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://biponnotes.iglyphic.com/diving-deeper-template-based-forms/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">321</post-id>	</item>
		<item>
		<title>Multiple Validators in Reactive Forms</title>
		<link>https://biponnotes.iglyphic.com/multiple-validators-in-reactive-forms/</link>
					<comments>https://biponnotes.iglyphic.com/multiple-validators-in-reactive-forms/#respond</comments>
		
		<dc:creator><![CDATA[bipon68]]></dc:creator>
		<pubDate>Mon, 06 Jan 2020 13:19:46 +0000</pubDate>
				<category><![CDATA[Angular Form]]></category>
		<category><![CDATA[angular form]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[reactive]]></category>
		<guid isPermaLink="false">https://bipon.me/?p=316</guid>

					<description><![CDATA[<p>profile.component.html profile.component.ts auth.service.ts user.module.ts user.routes.ts</p>
<p>The post <a href="https://biponnotes.iglyphic.com/multiple-validators-in-reactive-forms/">Multiple Validators in Reactive Forms</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></description>
										<content:encoded><![CDATA[<p><br>
<br>
<!--StartFragment--></p>


<p>profile.component.html</p>



<pre class="wp-block-code"><code>&lt;div>
  &lt;h1>Edit Your Profile &lt;/h1>
  &lt;hr>
  &lt;div class="col-md-4">
    &lt;form [formGroup]="profileForm" (ngSubmit)="saveProfile(profileForm.value)" autocomplete="off" novalidate>
      &lt;div class="form-group" [ngClass]="{'error' : !validateFirstName() }">
        &lt;label for="firstName">First Name:&lt;/label>
        &lt;em *ngIf="!validateFirstName() &amp;&amp; profileForm.controls.firstName.errors.required">Required&lt;/em>
        &lt;em *ngIf="!validateFirstName() &amp;&amp; profileForm.controls.firstName.errors.pattern">Must start with a letter&lt;/em>
        &lt;input formControlName="firstName" id="firstName" type="text" class="form-control" placeholder="First Name..." />
      &lt;/div>
      &lt;div class="form-group"  [ngClass]="{'error' : !validateLastName() }">
        &lt;label for="lastName">Last Name:&lt;/label>
        &lt;em *ngIf="!validateLastName()">Required&lt;/em>
        &lt;input formControlName="lastName" id="lastName" type="text" class="form-control" placeholder="Last Name..." />
      &lt;/div>

      &lt;button type="submit" class="btn btn-primary">Save&lt;/button>
      &lt;button type="button" class="btn btn-default" (click)="cancel()">Cancel&lt;/button>
    &lt;/form>
  &lt;div>
&lt;/div></code></pre>



<p>profile.component.ts</p>



<pre class="wp-block-code"><code>import { Component, OnInit } from '@angular/core'
import { FormControl, FormGroup, Validators } from '@angular/forms'
import { AuthService } from './auth.service'
import { Router} from '@angular/router'

@Component({
  templateUrl: './profile.component.html',
  styles: [`
    em {float:right; color:#E05C65; padding-left: 10px;}
    .error input {background-color:#E3C3C5;}
    .error ::-webkit-input-placeholder { color: #999; }
    .error ::-moz-placeholder { color: #999; }
    .error :-moz-placeholder { color:#999; }
    .error :ms-input-placeholder { color: #999; }
  `]
})
export class ProfileComponent implements OnInit {
  profileForm:FormGroup
  private firstName:FormControl
  private lastName:FormControl

  constructor(private router:Router, private authService:AuthService) {

  }

  ngOnInit() {
    this.firstName = new FormControl(this.authService.currentUser.firstName, [Validators.required, Validators.pattern('[a-zA-Z].*')])
    this.lastName = new FormControl(this.authService.currentUser.lastName, Validators.required)

    this.profileForm = new FormGroup({
      firstName: this.firstName,
      lastName: this.lastName
    })
  }

  saveProfile(formValues) {
    console.log('formValues : ', formValues);
    if (this.profileForm.valid) {
      this.authService.updateCurrentUser(formValues.firstName, formValues.lastName)
      this.router.navigate(['events'])
    }
  }

  validateFirstName() {
    return this.firstName.valid || this.firstName.untouched
  }
  
  validateLastName() {
    return this.lastName.valid || this.lastName.untouched
  }

  cancel() {
    this.router.navigate(['events'])
  }
       
}</code></pre>



<p>auth.service.ts </p>



<pre class="wp-block-code"><code>import { Injectable } from '@angular/core'
import { IUser } from './user.model'

@Injectable()
export class AuthService {

  currentUser:IUser
  
  loginUser(userName: string, password: string) {
    this.currentUser = {
      id: 1,
      userName: userName,
      firstName: 'Bipon',
      lastName: 'Biswas'
    }
  }

  isAuthenticated() {
    return !!this.currentUser;
  }

  updateCurrentUser(firstName:string, lastName:string) {
    this.currentUser.firstName = firstName
    this.currentUser.lastName = lastName
  }
}</code></pre>



<p>user.module.ts</p>



<pre class="wp-block-code"><code>import { NgModule } from '@angular/core'
import { CommonModule } from '@angular/common'
import { RouterModule } from '@angular/router'
import { FormsModule, ReactiveFormsModule } from '@angular/forms'

import { userRoutes } from './user.routes'
import { ProfileComponent } from './profile.component'
import { LoginComponent } from './login.component'

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    ReactiveFormsModule,
    RouterModule.forChild(userRoutes)
  ],
  declarations: [
    ProfileComponent,
    LoginComponent
  ],
  providers: [

  ]
})
export class UserModule { }</code></pre>



<p>user.routes.ts</p>



<pre class="wp-block-code"><code>import { ProfileComponent } from './profile.component'
import { LoginComponent } from './login.component'

export const userRoutes = [
  {path: 'profile', component: ProfileComponent},
  {path: 'login', component: LoginComponent}
]</code></pre>


<p><!--EndFragment--><br>
<br>
</p><p>The post <a href="https://biponnotes.iglyphic.com/multiple-validators-in-reactive-forms/">Multiple Validators in Reactive Forms</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://biponnotes.iglyphic.com/multiple-validators-in-reactive-forms/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">316</post-id>	</item>
		<item>
		<title>Validating Reactive Forms</title>
		<link>https://biponnotes.iglyphic.com/validating-reactive-forms/</link>
					<comments>https://biponnotes.iglyphic.com/validating-reactive-forms/#respond</comments>
		
		<dc:creator><![CDATA[bipon68]]></dc:creator>
		<pubDate>Mon, 06 Jan 2020 10:01:44 +0000</pubDate>
				<category><![CDATA[Angular Form]]></category>
		<category><![CDATA[angular form]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[reactive]]></category>
		<guid isPermaLink="false">https://bipon.me/?p=314</guid>

					<description><![CDATA[<p>profile.component.html profile.component.ts auth.service.ts user.module.ts user.routes.ts</p>
<p>The post <a href="https://biponnotes.iglyphic.com/validating-reactive-forms/">Validating Reactive Forms</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>profile.component.html</p>



<pre class="wp-block-code"><code>&lt;div>
  &lt;h1>Edit Your Profile &lt;/h1>
  &lt;hr>
  &lt;div class="col-md-4">
    &lt;form [formGroup]="profileForm" (ngSubmit)="saveProfile(profileForm.value)" autocomplete="off" novalidate>
      &lt;div class="form-group" [ngClass]="{'error' : !validateFirstName() }">
        &lt;label for="firstName">First Name:&lt;/label>
        &lt;em *ngIf="!validateFirstName()">Required&lt;/em>
        &lt;input formControlName="firstName" id="firstName" type="text" class="form-control" placeholder="First Name..." />
      &lt;/div>
      &lt;div class="form-group"  [ngClass]="{'error' : !validateLastName() }">
        &lt;label for="lastName">Last Name:&lt;/label>
        &lt;em *ngIf="!validateLastName()">Required&lt;/em>
        &lt;input formControlName="lastName" id="lastName" type="text" class="form-control" placeholder="Last Name..." />
      &lt;/div>

      &lt;button type="submit" class="btn btn-primary">Save&lt;/button>
      &lt;button type="button" class="btn btn-default" (click)="cancel()">Cancel&lt;/button>
    &lt;/form>
  &lt;div>
&lt;/div></code></pre>



<p>profile.component.ts</p>



<pre class="wp-block-code"><code>import { Component, OnInit } from '@angular/core'
import { FormControl, FormGroup, Validators } from '@angular/forms'
import { AuthService } from './auth.service'
import { Router} from '@angular/router'

@Component({
  templateUrl: './profile.component.html',
  styles: [`
    em {float:right; color:#E05C65; padding-left: 10px;}
    .error input {background-color:#E3C3C5;}
    .error ::-webkit-input-placeholder { color: #999; }
    .error ::-moz-placeholder { color: #999; }
    .error :-moz-placeholder { color:#999; }
    .error :ms-input-placeholder { color: #999; }
  `]
})
export class ProfileComponent implements OnInit {
  profileForm:FormGroup
  private firstName:FormControl
  private lastName:FormControl

  constructor(private router:Router, private authService:AuthService) {

  }

  ngOnInit() {
    this.firstName = new FormControl(this.authService.currentUser.firstName, Validators.required)
    this.lastName = new FormControl(this.authService.currentUser.lastName, Validators.required)

    this.profileForm = new FormGroup({
      firstName: this.firstName,
      lastName: this.lastName
    })
  }

  saveProfile(formValues) {
    console.log('formValues : ', formValues);
    if (this.profileForm.valid) {
      this.authService.updateCurrentUser(formValues.firstName, formValues.lastName)
      this.router.navigate(['events'])
    }
  }

  validateFirstName() {
    return this.firstName.valid || this.firstName.untouched
  }
  
  validateLastName() {
    return this.lastName.valid || this.lastName.untouched
  }

  cancel() {
    this.router.navigate(['events'])
  }
       
}</code></pre>



<p>auth.service.ts </p>



<pre class="wp-block-code"><code>import { Injectable } from '@angular/core'
import { IUser } from './user.model'

@Injectable()
export class AuthService {

  currentUser:IUser
  
  loginUser(userName: string, password: string) {
    this.currentUser = {
      id: 1,
      userName: userName,
      firstName: 'Bipon',
      lastName: 'Biswas'
    }
  }

  isAuthenticated() {
    return !!this.currentUser;
  }

  updateCurrentUser(firstName:string, lastName:string) {
    this.currentUser.firstName = firstName
    this.currentUser.lastName = lastName
  }
}</code></pre>



<p>user.module.ts</p>



<pre class="wp-block-code"><code>import { NgModule } from '@angular/core'
import { CommonModule } from '@angular/common'
import { RouterModule } from '@angular/router'
import { FormsModule, ReactiveFormsModule } from '@angular/forms'

import { userRoutes } from './user.routes'
import { ProfileComponent } from './profile.component'
import { LoginComponent } from './login.component'

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    ReactiveFormsModule,
    RouterModule.forChild(userRoutes)
  ],
  declarations: [
    ProfileComponent,
    LoginComponent
  ],
  providers: [

  ]
})
export class UserModule { }</code></pre>



<p>user.routes.ts</p>



<pre class="wp-block-code"><code>import { ProfileComponent } from './profile.component'
import { LoginComponent } from './login.component'

export const userRoutes = [
  {path: 'profile', component: ProfileComponent},
  {path: 'login', component: LoginComponent}
]</code></pre><p>The post <a href="https://biponnotes.iglyphic.com/validating-reactive-forms/">Validating Reactive Forms</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://biponnotes.iglyphic.com/validating-reactive-forms/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">314</post-id>	</item>
		<item>
		<title>Creating Your First Reactive Form</title>
		<link>https://biponnotes.iglyphic.com/creating-your-first-reactive-form/</link>
					<comments>https://biponnotes.iglyphic.com/creating-your-first-reactive-form/#respond</comments>
		
		<dc:creator><![CDATA[bipon68]]></dc:creator>
		<pubDate>Mon, 06 Jan 2020 09:46:04 +0000</pubDate>
				<category><![CDATA[Angular Form]]></category>
		<category><![CDATA[angular form]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[reactive]]></category>
		<guid isPermaLink="false">https://bipon.me/?p=312</guid>

					<description><![CDATA[<p>profile.component.html profile.component.ts auth.service.ts app.module.ts</p>
<p>The post <a href="https://biponnotes.iglyphic.com/creating-your-first-reactive-form/">Creating Your First Reactive Form</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>profile.component.html</p>



<pre class="wp-block-code"><code>&lt;div>
    &lt;h1>Edit Your Profile &lt;/h1>
    &lt;hr>
    &lt;div class="col-md-4">
      &lt;form [formGroup]="profileForm" (ngSubmit)="saveProfile(profileForm.value)" autocomplete="off" novalidate>
        &lt;div class="form-group">
          &lt;label for="firstName">First Name:&lt;/label>
          &lt;input formControlName="firstName" id="firstName" type="text" class="form-control" placeholder="First Name..." />
        &lt;/div>
        &lt;div class="form-group">
          &lt;label for="lastName">Last Name:&lt;/label>
          &lt;input formControlName="lastName" id="lastName" type="text" class="form-control" placeholder="Last Name..." />
        &lt;/div>
  
        &lt;button type="submit" class="btn btn-primary">Save&lt;/button>
        &lt;button type="button" class="btn btn-default" (click)="cancel()">Cancel&lt;/button>
      &lt;/form>
    &lt;/div>
  &lt;/div></code></pre>



<p>profile.component.ts</p>



<pre class="wp-block-code"><code>import { AuthService } from './auth.service';
import { Component, OnInit } from '@angular/core'
import { FormControl, FormGroup } from '@angular/forms'
import { Router } from '@angular/router';

@Component({
  templateUrl: './profile.component.html',
})
export class ProfileComponent implements OnInit{

  profileForm: FormGroup

  constructor(private authService: AuthService, private router: Router){}

  ngOnInit(){
    let firstName = new FormControl(this.authService.currentUser.firstName)
    let lastName = new FormControl(this.authService.currentUser.lastName)
    this.profileForm = new FormGroup({
      firstName: firstName,
      lastName: lastName
    })
  }

  cancel(){
    this.router.navigate(['events'])
  }
  saveProfile(formValues){
    this.authService.updateCurrentUser(formValues.firstName, formValues.lastName)
  }     
}</code></pre>



<p>auth.service.ts</p>



<pre class="wp-block-code"><code>import { Injectable } from '@angular/core';
import { IUser } from './user.model';


@Injectable()
export class AuthService{

    currentUser: IUser;
    //debugger;
    loginUser(userName: string, password: string){
        this.currentUser = {
            id: 1,
            userName: userName,
            firstName: 'Bipon',
            lastName: 'Biswas'
        }
    }
    isAuthenticated(){
        return !this.currentUser;
    }
    updateCurrentUser(firstName:string, lastName: string){
        this.currentUser.firstName = firstName
        this.currentUser.lastName = lastName
    }

}</code></pre>



<p>app.module.ts </p>



<pre class="wp-block-code"><code>import { ProfileComponent } from './profile.component';
import { NgModule } from '@angular/core'
import { CommonModule } from '@angular/common'
import { RouterModule } from '@angular/router'
import { userRoutes } from './user.routes'
import { LoginComponent } from './login.component';
import { FormsModule, ReactiveFormsModule } from '@angular/forms'

@NgModule({
    imports: [
        CommonModule,
        FormsModule,
        ReactiveFormsModule,
        RouterModule.forChild(userRoutes)
    ],
    declarations: [
        ProfileComponent,
        LoginComponent
    ],
    providers: [

    ]

})
export class UserModule{

}</code></pre><p>The post <a href="https://biponnotes.iglyphic.com/creating-your-first-reactive-form/">Creating Your First Reactive Form</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://biponnotes.iglyphic.com/creating-your-first-reactive-form/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">312</post-id>	</item>
		<item>
		<title>Creating Your First Template based Form</title>
		<link>https://biponnotes.iglyphic.com/creating-your-first-template-based-form/</link>
					<comments>https://biponnotes.iglyphic.com/creating-your-first-template-based-form/#respond</comments>
		
		<dc:creator><![CDATA[bipon68]]></dc:creator>
		<pubDate>Fri, 03 Jan 2020 04:58:37 +0000</pubDate>
				<category><![CDATA[Angular Form]]></category>
		<category><![CDATA[angular form]]></category>
		<category><![CDATA[Component]]></category>
		<category><![CDATA[form]]></category>
		<guid isPermaLink="false">https://bipon.me/?p=307</guid>

					<description><![CDATA[<p>Step 1: Create a component like login.component.html Step 2: login.component.ts</p>
<p>The post <a href="https://biponnotes.iglyphic.com/creating-your-first-template-based-form/">Creating Your First Template based Form</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Step 1: Create a component like login.component.html</p>



<pre class="wp-block-code"><code>&lt;h1>Login&lt;/h1>
&lt;hr>
&lt;div class="col-md-4">
  &lt;form #loginForm="ngForm" (ngSubmit)="login(loginForm.value)" autocomplete="off">
    &lt;div class="form-group" >
      &lt;label for="userName">User Name:&lt;/label>
      &lt;input (ngModel)="userName" name="userName" id="userName" type="text" class="form-control" placeholder="User Name..." />
    &lt;/div>
    &lt;div class="form-group" >
      &lt;label for="password">Password:&lt;/label>
      &lt;input (ngModel)="password" name="password" id="password" type="password" class="form-control"placeholder="Password..." />
    &lt;/div>
        
    &lt;button type="submit" class="btn btn-primary">Login&lt;/button>
    &lt;button type="button" class="btn btn-default">Cancel&lt;/button>
  &lt;/form>
&lt;/div>
&lt;!-- {{loginForm.value | json}} --></code></pre>



<p>Step 2: login.component.ts</p>



<pre class="wp-block-code"><code>import { Component } from '@angular/core'

@Component({
    templateUrl: './login.component.html'
})

export class LoginComponent{

    userName
    password
    
    login(formValues){
        console.log(formValues)
    }

}</code></pre><p>The post <a href="https://biponnotes.iglyphic.com/creating-your-first-template-based-form/">Creating Your First Template based Form</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://biponnotes.iglyphic.com/creating-your-first-template-based-form/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">307</post-id>	</item>
		<item>
		<title>Handling form control Events in Angular</title>
		<link>https://biponnotes.iglyphic.com/handling-form-control-events-in-angular/</link>
					<comments>https://biponnotes.iglyphic.com/handling-form-control-events-in-angular/#respond</comments>
		
		<dc:creator><![CDATA[bipon68]]></dc:creator>
		<pubDate>Thu, 12 Dec 2019 13:44:29 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[angular]]></category>
		<category><![CDATA[form]]></category>
		<guid isPermaLink="false">https://bipon.me/?p=199</guid>

					<description><![CDATA[<p>Step 1: user-settings-form.component.html file Step 2: user-settings-form.component.ts file</p>
<p>The post <a href="https://biponnotes.iglyphic.com/handling-form-control-events-in-angular/">Handling form control Events in Angular</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></description>
										<content:encoded><![CDATA[<p><strong>Step 1: </strong>user-settings-form.component.html file</p>



<pre class="wp-block-code"><code>&lt;form #form="ngForm" (ngSubmit)="onSubmit(form)">
    &lt;div class="form-group">
        &lt;label for="name">Name&lt;/label>
        &lt;input id="name" name="name" class="form-control" [(ngModel)]="userSettings.name" required #nameField="ngModel" (blur)="onBlur(nameField)" />
    &lt;/div>
	&lt;button class="btn btn-primary">Send&lt;/button>
&lt;/form></code></pre>



<p>Step 2: user-settings-form.component.ts file</p>



<pre class="wp-block-code"><code>import { NgForm, NgModel } from '@angular/forms';

 onBlur(field: NgModel){
    console.log('in onBlur: ', field.valid)
}</code></pre><p>The post <a href="https://biponnotes.iglyphic.com/handling-form-control-events-in-angular/">Handling form control Events in Angular</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://biponnotes.iglyphic.com/handling-form-control-events-in-angular/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">199</post-id>	</item>
		<item>
		<title>Submitting form with class binding in Angular</title>
		<link>https://biponnotes.iglyphic.com/submitting-form-with-class-binding-in-angular/</link>
					<comments>https://biponnotes.iglyphic.com/submitting-form-with-class-binding-in-angular/#respond</comments>
		
		<dc:creator><![CDATA[bipon68]]></dc:creator>
		<pubDate>Thu, 12 Dec 2019 12:39:38 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[angular]]></category>
		<category><![CDATA[angular form]]></category>
		<category><![CDATA[form]]></category>
		<guid isPermaLink="false">https://bipon.me/?p=195</guid>

					<description><![CDATA[<p>Step 1: user-settings-form.component.html file Step 2: user-settings-form.component.ts file Step 3: user-settings-form.component.css file</p>
<p>The post <a href="https://biponnotes.iglyphic.com/submitting-form-with-class-binding-in-angular/">Submitting form with class binding in Angular</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></description>
										<content:encoded><![CDATA[<p><strong>Step 1:</strong> user-settings-form.component.html file</p>



<pre class="wp-block-code"><code>&lt;form #form="ngForm" (ngSubmit)="onSubmit(form)">
    &lt;div class="form-group">
        &lt;label for="name">Name&lt;/label>
        &lt;input id="name" name="name" class="form-control" [(ngModel)]="userSettings.name" required #nameField="ngModel"
          [class.field-error]="form.submitted &amp;&amp; nameField.invalid"/>
    &lt;/div>
	&lt;button class="btn btn-primary">Send&lt;/button>
&lt;/form></code></pre>



<p><strong>Step 2:</strong> user-settings-form.component.ts file</p>



<pre class="wp-block-code"><code>import { NgForm, NgModel } from '@angular/forms';  
onSubmit(form: NgForm){
    console.log('in onSubmmit: ', form.valid);       
  }</code></pre>



<p><strong>Step 3:</strong> user-settings-form.component.css file</p>



<pre class="wp-block-code"><code>.field-error{
    border: 1px solid red;
}</code></pre><p>The post <a href="https://biponnotes.iglyphic.com/submitting-form-with-class-binding-in-angular/">Submitting form with class binding in Angular</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://biponnotes.iglyphic.com/submitting-form-with-class-binding-in-angular/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">195</post-id>	</item>
		<item>
		<title>HTML5 Field Validation in Angular</title>
		<link>https://biponnotes.iglyphic.com/html5-field-validation-in-angular/</link>
					<comments>https://biponnotes.iglyphic.com/html5-field-validation-in-angular/#respond</comments>
		
		<dc:creator><![CDATA[bipon68]]></dc:creator>
		<pubDate>Thu, 12 Dec 2019 09:48:35 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[angular]]></category>
		<category><![CDATA[angular form]]></category>
		<category><![CDATA[form]]></category>
		<guid isPermaLink="false">https://bipon.me/?p=180</guid>

					<description><![CDATA[<p>HTML 5 Validation Attributes required pattern minlength maxlength min max Step 1: user-settings-form.component.html file Step 2: user-settings-form.component.html file Step 3: user-settings-form.component.html file Step 4: user-settings-form.component.html file</p>
<p>The post <a href="https://biponnotes.iglyphic.com/html5-field-validation-in-angular/">HTML5 Field Validation in Angular</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></description>
										<content:encoded><![CDATA[<p><strong>HTML 5 Validation Attributes</strong></p>



<ul><li>required</li><li>pattern</li><li>minlength</li><li>maxlength</li><li>min</li><li>max</li></ul>



<p><strong>Step 1:</strong> user-settings-form.component.html file</p>



<pre class="wp-block-code"><code>&lt;form #form="ngForm" ngNativeValidate>
    &lt;div class="form-group">
        &lt;label for="name">Name&lt;/label>
        &lt;input id="name" name="name" class="form-control"  required />
        &lt;button class="btn btn-primary">Send&lt;/button>
     &lt;/div>
&lt;/form></code></pre>



<p><strong>Step 2:</strong> user-settings-form.component.html file</p>



<pre class="wp-block-code"><code>&lt;form #form="ngForm" ngNativeValidate>
    &lt;div class="form-group">
        &lt;label for="name">Name&lt;/label>
        &lt;input id="name" name="name" class="form-control"  pattern="B.*" />
   &lt;div>
    &lt;button class="btn btn-primary">Send&lt;/button>
&lt;/form>
</code></pre>



<p><strong>Step 3:</strong> user-settings-form.component.html file </p>



<pre class="wp-block-code"><code>&lt;form #form="ngForm" ngNativeValidate>
    &lt;div class="form-group">
        &lt;label for="name">Name&lt;/label>
        &lt;input id="name" name="name" class="form-control"  minlength="3" />
   &lt;div>
    &lt;button class="btn btn-primary">Send&lt;/button>
&lt;/form></code></pre>



<p><strong>Step 4:</strong> user-settings-form.component.html file  </p>



<pre class="wp-block-code"><code>&lt;form #form="ngForm" ngNativeValidate>
    &lt;div class="form-group">
        &lt;label for="name">Name&lt;/label>
        &lt;input id="name" name="name" class="form-control" type="number" min="3" max="300" />
   &lt;div>
    &lt;button class="btn btn-primary">Send&lt;/button>
&lt;/form></code></pre><p>The post <a href="https://biponnotes.iglyphic.com/html5-field-validation-in-angular/">HTML5 Field Validation in Angular</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://biponnotes.iglyphic.com/html5-field-validation-in-angular/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">180</post-id>	</item>
		<item>
		<title>Angular Form Technologies</title>
		<link>https://biponnotes.iglyphic.com/angular-form-technologies/</link>
					<comments>https://biponnotes.iglyphic.com/angular-form-technologies/#respond</comments>
		
		<dc:creator><![CDATA[bipon68]]></dc:creator>
		<pubDate>Wed, 11 Dec 2019 05:31:35 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[Angular Form]]></category>
		<category><![CDATA[angular]]></category>
		<category><![CDATA[angular form]]></category>
		<category><![CDATA[form]]></category>
		<guid isPermaLink="false">https://bipon.me/?p=163</guid>

					<description><![CDATA[<p>Template-driven Forms Use a Component&#8217;s Template Unit Test Against DOM Reactive Forms Use a Component&#8217;s Template Create a Form Model in Typescript (this must by in sync with the template) Unit Test Against Form Model Validation in Form Model</p>
<p>The post <a href="https://biponnotes.iglyphic.com/angular-form-technologies/">Angular Form Technologies</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></description>
										<content:encoded><![CDATA[<h4>Template-driven Forms</h4>



<ul><li>Use a Component&#8217;s Template</li><li>Unit Test Against DOM</li></ul>



<h4>Reactive Forms</h4>



<ul><li>Use a Component&#8217;s Template</li><li>Create a Form Model in Typescript (this must by in sync with the template)</li><li>Unit Test Against Form Model</li><li>Validation in Form Model</li></ul><p>The post <a href="https://biponnotes.iglyphic.com/angular-form-technologies/">Angular Form Technologies</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://biponnotes.iglyphic.com/angular-form-technologies/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">163</post-id>	</item>
	</channel>
</rss>
