I am working on an application with AngularJS andAngular Material.
In the template I have:
<md-input-container>
<label>{{::"Users" | translate }}</label>
<md-select md-container-class="default-select"
ng-model="$ctrl.filter.user"
ng-change="$ctrl.filterPostsByUser()">
<md-option ng-value="user"
ng-repeat="user in $ctrl.UsersService.config.users"
ng-selected="{{user.UserName == $ctrl.filter.currentUser.userName ? 'selected' : ''}}">
{{ user.userName }}
</md-option>
</md-select>
</md-input-container>
In the script (JavaScript) file:
filterPostsByUser() {
if (this.filter.user) {
this.userID = this.filter.user.id;
}
}
If I inspect the md-select element, I can see the current user's name (let's say "John Doe") option has ng-selected="selected", yet visually, the md-select doesn't show "John Doe", but the generic, default placeholder "Users".
What is missing?
Maybe, following code will help you