Angular Material: mat-select not selecting default

后端 未结 17 1440
不思量自难忘°
不思量自难忘° 2020-11-28 23:18

I have a mat-select where the options are all objects defined in an array. I am trying to set the value to default to one of the options, however it is being left selected

17条回答
  •  心在旅途
    2020-11-28 23:56

    My solution is little tricky and simpler.

    {{ option.name }}

    I just made use of the placeholder. The default color of material placeholder is light gray. To make it look like the option is selected, I just manipulated the CSS as follows:

    ::ng-deep .mat-select-placeholder {
        color: black;
    }
    

提交回复
热议问题