Jgascona
Jgascona

Reputation: 1259

How to disable the drag option on Angular material Slide toggle component

I am including the component Slide toggle of Angular Material into my view and I want to disable the drag option and just allow the click function.

This toggle is not within a form, it is just in my DOM in order to change a value with the NgModel functionality in my component. I've already tried with the disableDragValue API native funtion of material, but it doesn´t disable the drag option.

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

Expected: Disable the possibility of drag the slider toggle Result: I can´t disable the drag option on it

Upvotes: 4

Views: 1933

Answers (1)

jna
jna

Reputation: 996

For me, this works..

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}},
  ]
})

Upvotes: 2

Related Questions