Issue
I want to set a default option value for select tag, the values are declared as table in my component and showed with ngFor directive :
<form>
<div class="form-group col-4">
<span class="badge badge-theme mb-3">Quantité</span>
<select class="form-control" id="exampleFormControlSelect1">
<option *ngFor="let quantity of Quantities" [ngValue]="quantity">{{quantity}}</option>
</select>
</div>
<div class="form-group col-4">
<span class="badge badge-theme mb-3">Message personnalisé</span>
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3"></textarea>
</div>
</form>
components.ts
Quantities = Array(50).fill(0).map((x,i)=>i);
Solution
I have created Stackblitz.
What I did is created a variable in compoent and then bonded it with select tag. [(ngModel)]="selectedValue"
.
The variable then can be used as per your logic.
Answered By - Plochie
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.