How to dynamically enable or disable ion-range-slider using Ionic 3 and Angular 5?

2.9k Views Asked by At

I have implemented a slider using ion-range-slider. It is having a disable option to make the slider enable or disable. But I need to make it enable/disable dynamically.

I tried this way. I am not able to achieve this. Please help me what I need to do? Her's the code.

<ion-range-slider #advancedSliderElement
                  type="single"
                  [min]="0"
                  max="100"
                  from={{r.rule}}    
                  from_shadow="true"
                  to="40"
                  to_shadow="true"
                  grid="true"
                  grid_num="10"
                  prefix=""
                  postfix=""
                  decorate_both="false"
                  disable = "rangeDisable"
                  (onChange)="update(advancedSlider, $event)"
                  (onFinish)="finish(advancedSlider, $event, i)">
            </ion-range-slider>

My manage.ts code is:

export class ManagePage {
public rangeDisable: boolean = true;
constructor(public navCtrl: NavController) {}
enableSave() {
        this.rangeDisable = false;
    }
}

I need to make slider enable on click of a button

<button class="button-border" ion-button round (click)="enableSave()" ><i class="material-icons">create</i> </button>

Please guide me how to proceed.

1

There are 1 best solutions below

3
On BEST ANSWER

You just need to use [] to bind your boolean variable to the property of the component.

<ion-range-slider #advancedSliderElement
                  type="single"
                  min="0"//no need to bind if you are sending a value
                  max="100"
                  [from]="r.rule"  
                  from_shadow="true"
                  to="40"
                  to_shadow="true"
                  grid="true"
                  grid_num="10"
                  prefix=""
                  postfix=""
                  decorate_both="false"
                  [disable] = "rangeDisable"//here
                  (onChange)="update(advancedSlider, $event)"
                  (onFinish)="finish(advancedSlider, $event, i)">
            </ion-range-slider>