0

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 Answer 1

1

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>
Sign up to request clarification or add additional context in comments.

3 Comments

thank you so much, I didn't know we can bind other properties with just giving brackets.
@Darshantheerth you might want to check out the Angular tutorial, this will prevent a lot of headache in the future ;) angular.io/tutorial
angular.io/guide/template-syntax its angulars data binding.. your library is also built on angular and uses input() to bind data. I suggest you go through the docs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.