How do I set default value on md-select component from angular 2 material design?

后端 未结 3 1393
慢半拍i
慢半拍i 2021-02-18 20:23

I have the following select component that gets populated from a data coming from a rest api. How Can I set default selected value on md-select?

  

        
3条回答
  •  天涯浪人
    2021-02-18 20:49

    When you use Objects in md-option value, the object reference of the default value and the correponding option in the options list are not equal.

    To fix this, you need to override the default value using the correponding option in the options list before setting the FormGroup.

    Check this example

提交回复
热议问题