Reputation: 57231
I have a select with options:
<select (change)="myFunction(fcName)"
formControlName="{{ fcName }}" class="form-control">
<option *ngFor="let type of form.choices[fcName]" [ngValue]="type.id">{{ type.text }}</option>
</select>
Sorry code is not the easiest to read but it works fine. However, I want myFunction
to execute, even if the selected option is the current option.
I understand why (change)
does not work since there is no change if the same option is selected. (click)
fires too frequently. Is there another option?
Upvotes: 0
Views: 151
Reputation: 26190
(click)
should do the job but instead of placing it on the select
element, add it to the option
element.
<select formControlName="{{ fcName }}" class="form-control">
<option *ngFor="let type of form.choices[fcName]" [ngValue]="type.id" (click)="onClickFunction(type)">{{ type.text }}</option>
</select>
Upvotes: 1