Registration Form in Angular 8

Updated: Nov 5, 2020

To create a new workspace and an initial app project
  1. Ensure that you are not already in an Angular workspace folder. For example, if you have previously created the Getting Started workspace, change to the parent of that folder.

  2. Run the CLI command ng new and provide the name Registration, as shown here:

ng new Registration 

3. The ng new command prompts you for information about features to include in the initial app project. Accept the defaults by pressing the Enter or Return key.

Angular components

The page you see is the application shell. The shell is controlled by an Angular component named AppComponent.

Components are the fundamental building blocks of Angular applications. They display data on the screen, listen for user input, and take action based on that input.

Make changes to the application

Open the project in your favorite editor or IDE and navigate to the src/app folder to make some changes to the starter app.


the component template, written in HTML.

<form [formGroup]="frmValue" (ngSubmit)="login()">
 <td>Reg No:</td> <td><input type="number" placeholder="Registration No." formControlName="regNo"></td>
 <td>Name:</td><td><input type="text" placeholder="name" formControlName="fristName"></td>
 <td>Descipline:</td><td><select formControlName="descipline">
 <option *ngFor="let dis of Discipline" value="{{dis}}">{{dis}}</option>
 <td>Gender:</td><td><input type="radio" value="male" name="gender" formControlName="gender">male
 <input type="radio" value="female" name="gender" formControlName="gender">female</td>
 <div *ngFor="let subject of subjectData">
 <input type="checkbox" (change)="onChange(, $">
 <td><input type="submit" value="View on Console"></td><td><input type="submit" value="Store in File"></td>


the component class code, written in TypeScript.

import { Component, OnInit } from '@angular/core';
import { FormGroup, FormBuilder, FormControl, FormArray  } from '@angular/forms';

export interface Subject {
 id: number;
 name: string;
 selector: 'app-login',
 templateUrl: './login.component.html',
 styleUrls: ['./login.component.css']
export class LoginComponent implements OnInit {

 constructor(private formBuilder:FormBuilder) { }

 Discipline: any = ['MCS', 'WMC', 'DIF'];
 subjectData: Subject[] = [
    { id: 0, name: 'MPL' },
    { id: 1, name: 'OOP' },
    { id: 2, name: 'OS' },
    { id: 3, name: 'PF' },
    { id: 2, name: 'VP' }
 ngOnInit(): void {{
 gender: [''],
 name: this.formBuilder.array([])
 onChange(namestringisCheckedboolean) {
 const sub = ( as FormArray);
 if (isChecked) {
 sub.push(new FormControl(name));
    } else {
 const index = sub.controls.findIndex(x => x.value === name);

 console.log("Registration No. ....."+this.frmValue.value.regNo);
 console.log("Name .............."+this.frmValue.value.fristName);
 console.log("Gender ....... ...."+this.frmValue.value.gender);
 console.log("descipline ........"+this.frmValue.value.descipline);
 console.log("Subject Name ........";


Routing basically means navigating between page.

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { LoginComponent } from './login/login.component';

const routes: Routes = [

 imports: [RouterModule.forRoot(routes)],
 exports: [RouterModule]
export class AppRoutingModule { }
export const routingComponents=[LoginComponent



the main parent component app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule,ReactiveFormsModule }  from '@angular/forms';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

 declarations: [
 imports: [
 providers: [],
 bootstrap: [AppComponent]
export class AppModule { }

Run the application

The ng serve command launches the server, watches your files, and rebuilds the app as you make changes to those files.

The --open (or just -o) option automatically opens your browser to http://localhost:4200/.

 ng serve -o


Contact Us

Tel: (+91) 0120  4118730  

Time :   10 : 00  AM -  08 : 00 PM IST 

Registered address: G-69, Sector 63, 

 Noida - 201301, India

We Provide Services Across The different countries

USA    Australia   Canada   UK    UAE    Singapore   New Zealand    Malasia   India   Ireland   Germany

CodersArts is a Product by Sofstack Technology Solutions Pvt. Ltd.

  • CodersArts | Linkedin
  • Instagram