如何从像此代码的按钮中打开md-select?
<md-select placeholder="Cuestionario" (ngModelChange)="set_survey($event)">
<option [ngValue]='undefined' disabled selected>Selecciona un Cuestionario</option>
<md-option *ngFor="let survey of surveys" [value]="survey.id">{{ survey.nombre }}</md-option>
</md-select>
<button (click)="md-select.open()"></button>
答案 0 :(得分:2)
我希望md-select
是角度材质成分,
如果是,请尝试以下,
<md-select #surveyselector placeholder="Cuestionario" (ngModelChange)="set_survey($event)">
<option [ngValue]='undefined' disabled selected>Selecciona un Cuestionario</option>
<md-option *ngFor="let survey of surveys" [value]="survey.id">{{ survey.nombre }}</md-option>
</md-select>
<button (click)="surveyselector.open()"></button>
以下是Plunker!!
希望这会有所帮助!!
答案 1 :(得分:0)
我没有测试过,但我认为这样可行。
<md-select #mdSelect placeholder="Cuestionario" (ngModelChange)="set_survey($event)">
<option [ngValue]='undefined' disabled selected>Selecciona un Cuestionario</option>
<md-option *ngFor="let survey of surveys" [value]="survey.id">{{ survey.nombre }}</md-option>
</md-select>
<button (click)="mdSelect.open()"></button>