0

This is the view:

<select name="day" (change)="showHourRange(value)">
  <option selected="true" disabled="disabled">Choose one</option>
  <option *ngFor="let delivery of deliveries$ | async"
          [value]="delivery.day">{{delivery.day | date:'dd/MM/yy'}}
  </option>
</select>

The value logs undefined when the method is called even if it is correctly shown inside the rendered options.

1 Answer 1

2

Use [ngModel] and ngModelChange

<select name="day" [ngModel]="selectedDelovery" (ngModelChange)="showHourRange($event)">
  <option *ngFor="let delivery of deliveries$ | async"
          [value]="delivery.day">{{delivery.day | date:'dd/MM/yy'}}
  </option>
</select>
Sign up to request clarification or add additional context in comments.

3 Comments

Although this solves the problem, it also rises another one. The placeholder static option now has disappeared. I've updated the view code, this line was removed for legibility.
@cerealex you mean the disabled choose one option is no longer in the DOM?
Strangely enough, it is in the dom, but not shown as selected option in the view... (The box is empty)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.