Ramón Wilhelm
Ramón Wilhelm

Reputation: 997

AngularJS Material: Cannot get value of md-select

I've got a AngularJS Material Select:

       <md-input-container style="margin-right: 10px;">
            <label>Roll</label>
            <md-select id="acc-type" required="" ng-model="rolle">
                <md-option ng-selected="true" value="Tenant">Tenant</md-option>
                <md-option value="Lessor">Lessor</md-option>
            </md-select>
        </md-input-container>

and I want to get the actual selected option. I tried it with

    var e = document.getElementById("acc-type");
    var selectedItem = e.value;

but all I receive is undefined. Is there any option to get the value of a md-select in AngularJS?

Upvotes: 0

Views: 358

Answers (2)

Ravi Shankar Bharti
Ravi Shankar Bharti

Reputation: 9268

Since you have already defined ng-model="rolle" in your md-select, you can access it via $scope.rolle

Try:

var selectedItem = $scope.rolle

Upvotes: 2

Its in angular Js and model is already assigned so try Try

 console.log($scope.rolle);

Upvotes: 1

Related Questions