Form Select Dropdown with Angular Material(mat-select)

Today, We want to share with you Form Select Dropdown with Angular Material(mat-select) Example.In this post we will show you Angular 9 Material Select Dropdown – mat-select in Angular, hear for Angular Material Form Controls Select (mat-select) Example we will give you demo and example for implement.In this post, we will learn about Angular Material Select Dropdown, Emit Whole Object Item, not just a value with an example.

Form Select Dropdown with Angular Material(mat-select) Example

There are the Following The simple About angular material dropdown Full Information With Example and source code.

As I will cover this Post with live Working example to develop mat-select selected value, so the angular-material-mat-select-dynamic-data-binding-in-angular is used for this example is following below.

Angular is a platform for building mobile & desktop web Based user friendly and light weight applications.Angular,It’s TypeScript-based open-source Angularjs web application framework.

Keywords :

Make New App & Add Material Design

ng new app-material

ng add @angular/material

Example 1: Basic Material Select Dropdown

src/app/app.module.ts


import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
  
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
  
import {MatSelectModule} from '@angular/material/select';
  
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    MatSelectModule,
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

src/app/app.component.html


Angular Basic mat-select Example - www.pakainfo.com

Select blogspot {{pageofblog.viewValue}}

src/app/app.component.ts


import { Component } from '@angular/core';
  
interface blogspot {
  value: string;
  viewValue: string;
}
   
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'app-material3';
  
  pageofblogs: blogspot[] = [
    {value: '1', viewValue: 'Pakainfo.com.com'},
    {value: '2', viewValue: 'Pakainfo.com.com'},
    {value: '3', viewValue: 'infinityknow.com.com'}
  ];
}

Example 2: Material Select Dropdown with Reactive Form

src/app/app.module.ts


import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
  
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
  
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import {MatSelectModule} from '@angular/material/select';
import {MatButtonModule} from '@angular/material/button';
  
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    FormsModule,
    ReactiveFormsModule,
    MatSelectModule,
    MatButtonModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

src/app/app.component.html


Angular Material Select Box Example - Pakainfo.com.com

Select blogspot {{pageofblog.viewValue}} Please select pageofblog

src/app/app.component.ts


import { Component } from '@angular/core';
import { FormBuilder, FormGroup, Validators} from '@angular/forms';
  
interface blogspot {
  value: string;
  viewValue: string;
}
  
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'app-material2';
  
  pageofblogs: blogspot[] = [
    {value: '1', viewValue: 'Pakainfo.com.com'},
    {value: '2', viewValue: 'Pakainfo.com.com'},
    {value: '3', viewValue: 'infinityknow.com.com'}
  ];
  
  form: FormGroup = new FormGroup({});
  
  constructor(private fb: FormBuilder) {
  
    this.form = fb.group({
      pageofblog: ['', [Validators.required]],
    })
  }
   
  get f(){
    return this.form.controls;
  }
    
  submit(){
    console.log(this.form.value);
  }
}
Web Programming Tutorials Example with Demo

Read :

Summary

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

I hope you get an idea about angular material select.
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.

Leave a Comment