【问题标题】:How to disable the drag option on Angular material Slide toggle component如何禁用 Angular 材质 Slide 切换组件上的拖动选项
【发布时间】:2019-09-30 04:04:54
【问题描述】:

我将 Angular Material 的组件 Slide toggle 包含到我的视图中,我想禁用拖动选项并只允许单击功能。

此切换不在表单中,它只是在我的 DOM 中,以便使用我的组件中的 NgModel 功能更改值。我已经尝试过使用材料的 disableDragValue API 原生功能,但它不会禁用拖动选项。

<mat-slide-toggle [checked]="true" (click)="segmentationEvent()">Segmentation</mat-slide-toggle>

预期:禁用拖动滑块切换的可能性 结果:我无法禁用它的拖动选项

【问题讨论】:

    标签: angular angular-material


    【解决方案1】:

    对我来说,这行得通..

    import { MAT_SLIDE_TOGGLE_DEFAULT_OPTIONS } from '@angular/material';
    
    @Component({
      selector: 'app-selector',
      templateUrl: './template.html',
      providers: [
        {provide: MAT_SLIDE_TOGGLE_DEFAULT_OPTIONS , useValue: {disableToggleValue: false, disableDragValue: true}},
      ]
    })
    

    【讨论】:

      猜你喜欢
      • 2019-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-21
      • 2020-04-05
      • 1970-01-01
      • 1970-01-01
      • 2019-11-27
      相关资源
      最近更新 更多