Angular mat-selection-list, How to make single checkbox select similar to radio button?

后端 未结 14 1711
北恋
北恋 2021-02-18 21:22

How to make make single checkbox select from mat-selection-list. Similar to radio button which accepts one value from group of values.

14条回答
  •  执笔经年
    2021-02-18 21:42

    you can declare the [selected] attribute of mat-list-option

    for example:

    
        
            {{item.name}}
        
    
    

    by this way you reach just one selection without changing any MatSelectionList hidden property.

    Also you can do it by replacing ngModel with controller logic, by this way you will save the last selection object in class variable.

    see also Binding an Angular Material Selection List

提交回复
热议问题