Displaying ngModel value for mat-select

前端 未结 1 455
温柔的废话
温柔的废话 2021-01-18 02:49

I am using Angular Material Select to display holidays. When the user selects a holiday, I would like to display the date instead of the holiday name. For example, if the us

1条回答
  •  有刺的猬
    2021-01-18 03:43

    The options value is set to the holiday object and [(ngModel)] is set to the date property of the selected event, in your case holiday.date.

    So the select looks for the option with value holiday.date but your options have value holiday.

    The select [(ngModel)] has to correlate to the value of its option.

    [value]="holiday.date"
    

    Updated Plunker fork

    0 讨论(0)
提交回复
热议问题