Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get value of md-select from template reference variable, Material for Angular 2

This isn't showing the selected value like it would if it were a textbox instead of a select. What's wrong?

<md-select #mySelect>
    <md-option value="1">one</md-option>
    <md-option value="2">two</md-option>
</md-select>
{{ mySelect.value }}
like image 276
Alexander Taylor Avatar asked Jan 26 '17 01:01

Alexander Taylor


1 Answers

Try #variable.selected.value like this:

<md-select #mySelect>
    <md-option value="1">one</md-option>
    <md-option value="2">two</md-option>
</md-select>
<div *ngIf="mySelect.selected">
    {{mySelect.selected.value}}
</div>
like image 54
Alexander Taylor Avatar answered Oct 21 '22 14:10

Alexander Taylor