Selected options using md-select and Material Design for Angular

How to set the default option (i.e. selected) to Select Component when using Material Design for Angular ?

<md-select placeholder="Angular2 Material">
  <md-option>One</md-option>
  <md-option selected>Two</md-option>
  <md-option ng-selected="true">Three</md-option>
</md-select>

The SO search leads me to:

I tried both attributes ng-selected="true"and selectedbut does not work.

Plunker: https://plnkr.co/edit/EyC6wpUpgZEihlGclDUU?p=preview

To be clear, I'm not using Material Design for AngularJS Apps . I am using Material Design for Angular .

+4
1

export class SelectOverviewExample {
  myValue = 'Two';
}

, md-option value. ngModel.

<md-select placeholder="Angular2 Material" [(ngModel)]="myValue">
  <md-option>One</md-option>
  <md-option value="Two">Two</md-option>
  <md-option>Three</md-option>
</md-select>
+4

Source: https://habr.com/ru/post/1672044/


All Articles