Angular 9/8 Material Input Box Examples

Today, We want to share with you Angular 9/8 Material Input Box Examples.In this post we will show you Angular Material Form Controls, Form Field and Input Examples, hear for angular material form validation we will give you demo and example for implement.In this post, we will learn about Material Input Box with Reactive Form with an example.

Angular 9/8 Material Input Box Examples

There are the Following The simple About Modal Popup Example and Tutorial with Angular 9/8 Material Full Information With Example and source code.

Read Also:  Abstract Class in C# Tutorial with Example

As I will cover this Post with live Working example to develop Angular 9/8 Material Examples: Date Picker, Input, CheckBox, so the mat-input-container is used for this example is following below.

Angular Material Input Box Example

src/app/app.module.ts

src/app/app.component.html

<h1>Angular Material Input Box Example - pakainfo.com</h1>
  
<form [formGroup]="form" (ngSubmit)="submit()">
  
  <mat-form-field class="example-full-width">
      <mat-label>Name</mat-label>
      <input matInput placeholder="Ex. Kohali" formControlName="name">
      <mat-error *ngIf="form.get('name').hasError('required')">
        Name Field is required
      </mat-error>
  </mat-form-field>
   
  <mat-form-field class="example-full-width">
      <mat-label>Email</mat-label>
      <input matInput placeholder="Ex. [email protected]" formControlName="email">
      <mat-error *ngIf="form.get('email').hasError('required')">
        Email Field is required
      </mat-error>
      <mat-error *ngIf="form.get('email').hasError('email')">
        Must be enter valid email
      </mat-error>
  </mat-form-field>
   
  <button mat-raised-button color="purple">Submit</button>
</form>

src/app/app.component.ts

import { Component } from '@angular/core';
  
import { FormBuilder, FormGroup, Validators} from '@angular/forms';
  
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'app-gretting';
  
  form: FormGroup = new FormGroup({});
   
  constructor(private fb: FormBuilder) {
  
    this.form = fb.group({
      name: ['', [Validators.required]],
      email: ['', [Validators.required, Validators.email]],
    })
  }
    
  get f(){
    return this.form.controls;
  }
   
  submit(){
    console.log(this.form.value);
  }
}

Web Programming Tutorials Example with Demo

Read :

Read Also:  Laravel Pivot Tables Tutorial Example

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about mat-form-field appearance=outline.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.