Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

281
Views
How to reset second select box options to default value if we changes options in first select box using Angular

Have two selectboxes, if we select item in first select box and select one option in second select box. And If we select another option in first select box, need to reset back to default value like 'Select Time'. I tried using below code, I can able to select but unable to reset to back to default value, still selecting previously selecting value.

 public validTime = ['8', '9', '10', '11', '12', '1', '2', '3', '4'];
  public validTimeOptions = this.validTime;
  output = "....";

  selectedFood: string;

  foods = [
    {value: 'product10', viewValue: 'Monday'},
    {value: 'product20', viewValue: 'Tuesday'},
    {value: 'product30', viewValue: 'Wednesday'},
    {value: 'product40', viewValue: 'Thursday'},
    {value: 'product40', viewValue: 'Friday'},
  ];


  onFoodSelection() {
    this.output = this.selectedFood;
    this.validTime = this.validTime;
  }

HTML:

  <select placeholder="Favorite food" [(ngModel)]="selectedFood" (ngModelChange)="onFoodSelection()">
    <option *ngFor="let food of foods" [value]="food.value">
       {{ food.viewValue }}
    </option>
  </select>


  <select id="suspensionTime" class="kite-form-control" (click)="changeTimeUpdate()">
    <option [ngValue]="null" selected disabled>Select Time</option>
    <option *ngFor="let time of validTimeOptions" [ngValue]="time">{{ time }}</option>
  </select>

Stackblitz

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You need to link suspensionTime select with an ngModel in order to update the value on day change.

// app.component.ts
selectedTime: string;
onFoodSelection() {
  this.output = this.selectedFood;
  this.validTime = this.validTime;
  this.selectedTime = null;
}

// app.component.html
<select id="suspensionTime" class="kite-form-control" (click)="changeTimeUpdate()"
[(ngModel)]="selectedTime">

Check this Stackblitz.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!