typescript - An issue with angular 4 select element behavior on selecting an option -
i building angular 4 (v4.2.5 cli) app , have encountered following issue:
i using select element in following manner:
<div class="col-xs-8"> <select class="col-xs-12" [(ngmodel)]="roleid" (ngmodelchange)="changeselected($event)"> <option *ngfor="let type of usertypes" [ngvalue]="type" [selected]="type.name === role">{{ type.name }}</option> </select> </div> essentialy wanted bind selection event specific action in component class:
changeselected(event) { this.roleid = event.id; } and works, when select 1 of options event fired , field "roleid" gets set. however, selected item disappears view (i remain empty option). testing solution in chrome. [ngvalue] attribute binding interferes in way [selected] attribute binding? missing something? in advance help.
when want change value of select, don't need trigger event that. delete ngmodelchange attribute, roleid property have value selected in way.
Comments
Post a Comment