ngx-slider icon indicating copy to clipboard operation
ngx-slider copied to clipboard

Programmatically disable and enable the slider

Open eulersson opened this issue 3 years ago • 0 comments

I can't manage to enable or disable the component unless I get hold of the component in my hosting component and interact with its API:

@Component({
  selector: 'mycomp',
  template: `<button (click)="disableSlider()">Disable Slider</button><ngx-slider #mySlider ...></ngx-slider>`
  ...
})
export class MyCompComponent {
    @ViewChild('mySlider') sliderComponent!: any; // <-- I would like to use SliderComponent from this tool package.

    disableSlider() {
      this.sliderComponent?.setDisabledState(true);
    }
    
}

Even if I do this the slider can still be moved despite being in disabled state.

I also tried playing with the Options's disabled from here and it won't work.

Wouldn't it be better to have a [disabled] @Input in the component?

How can I easily change the disabled state and enable it back on?

eulersson avatar Nov 19 '21 17:11 eulersson