I have this following code :
<md-select ng-change="updateView()"
ng-model="userSelected"
ng-if="authuser.privilege >= 3">
<md-option ng-repeat="user in users"
ng-value="user">{{user.name}}</md-option>
</md-select>
But in my upadateView() when I log the userSelected I always get this whatever I choose :
Object {$$mdSelectId: 1}
I initialise it in my controller like this
$scope.personneSelected = {};
Did I miss something ?
I solved my problem by using ng-show instead of the ng-if.
You should initialise the ng-model variable with one of the default values that appears in the users collection to get it right.
Refer to the post https://stackoverflow.com/a/12654812/1196544
Also, whatever that's been returned should have been an object of 'user' since angularJS stores the object itself as the value of every option for the select.
Use console.dir() instead of console.log() to view the object properties (in chrome).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With