javascript - md-select error message trigger in angular material -
i have md-select
, corresponding submit button use call web-service , pass data md-select
(i not using forms here):
<div class="col-8"> <md-select placeholder="select user" class="custom-select" id="user" name="user" [(ngmodel)]="user" floatplaceholder="never"> <md-option *ngfor="let user of users| keys" [value]="user.key">{{user.value}}</md-option> </md-select> </div> <div class="col-2 mb-3"> <button type="button" class="btn blue-btn" (click)="ws(user)">view details</button> </div>
upon submit , before calling web-service, want check whether option has been selected , display error message (angular material style) in case none is. angular documentation mentions errorstatematcher
mdinput
none md-select
.
make use of ngmodelchange
<md-select placeholder="select user" class="custom-select" id="user" name="user" [(ngmodel)]="user" floatplaceholder="never" (ngmodelchange)="changeselected($event)"> <md-option *ngfor="let user of users| keys" [value]="user.key">{{user.value}}</md-option> </md-select>
component
changeselected(event) { this.user = event.user; }
Comments
Post a Comment