Angular 9/8 Select Dropdown | Get Selected DropDown Value on Change Event

Today, We want to share with you Angular 9/8 Get Selected DropDown Value on Change Event – Angularjs 9/8 Select Dropdown.In this post we will show you Angular 9/8 Select Dropdown Example, hear for angular 6 reactive forms select option we will give you demo and example for implement.In this post, we will learn about Bind Select DropDown List in Angular 8 with an example.

Angular 9/8 Get Selected DropDown Value on Change Event

There are the Following The simple About Angular 7|8|9 Select Dropdown Examples with Reactive Forms Full Information With Example and source code.

As I will cover this Post with live Working example to develop Angular 8/9 Select Dropdown Tutorial with Reactive Forms, so the angular 7 reactive forms select option is used for this example is following below.

Phase 1: Import FormsModule

src/app/app.module.ts

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

Phase 2: Form with ngModel

src/app/app.component.html

<div class="bdy-cart container dsp">
    <h1>Angular Select Dropdown Example - pakainfo.com</h1>
      
    <form [formGroup]="form" (ngSubmit)="submit()">
          
        <div class="corona form-group lg10">
            <label for="blogspot">Blogspot:</label>
            <select formControlName="blogspot" class="form-control" (change)="changeBlogspot($event)">
                <option disabled>Select Blogspot</option>
                <option>Choose Blogspot</option>
                <option *ngFor="let web of blogspotList">{{web}}</option>
            </select>
            <div *ngIf="f.blogspot.touched && f.blogspot.invalid" class="alert alert-danger">
                <div *ngIf="f.blogspot.errors.required">Name is required.</div>
            </div>
        </div>
      
        <button class="btn btn-primary" type="submit" [disabled]="!form.valid">Submit</button>
    </form>
</div>

Phase 3: updated Ts File

src/app/app.component.ts

import { Component } from '@angular/core';
import { FormGroup, FormControl, Validators} from '@angular/forms';
  
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  blogspotList: any = ['pakainfo.com', 'ministackoverflow.com', 'infinityknow.com']
  
  form = new FormGroup({
    blogspot: new FormControl('', Validators.required)
  });
  
  get f(){
    return this.form.controls;
  }
  
  submit(){
    console.log(this.form.value);
  }
  changeBlogspot(e) {
    console.log(e.target.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 8 select required validation.
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.


Related FAQ

Here are some more FAQ related to this Article:

  1.   Send email via Gmail SMTP server in Laravel 7/6
  2.   Dropdown ng-change Event using Angular Example
  3.   Ajax Autocomplete Live Search Suggestion using PHP MySQL
  4.   Check if Checkbox Checked Unchecked using Angular Example
  5.   PHP Create zip archive and Download Zip File using ZipArchive
  6.   Angular 9/8 Get Selected DropDown Value on Form Submit
  7.   Ng-Bind Directive using Angular Example
  8.   Bootstrap Toggle switch Update Database field using Ajax
  9.   Implement Yajra Datatables in Laravel 7 Application
  10.   Menu Based Program in PHP Using Switch case