Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I call a method if my Ionic 2 range slider changes value

Tags:

angular

ionic2

I'm working on an Ionic 2 app and playing around with the range, as described here: https://ionicframework.com/docs/v2/api/components/range/Range/

Call me crazy, but I can't find anywhere on google how the range component can call a method in my .ts class once the value has changed.

Something like a button, which goes like this:

<button ion-button (click)="myMethod($event)">

Of course, I need the value of the slider. In my case I defined it as follows:

  <ion-range min="0" max="10" color="danger">
    <ion-label range-left>0</ion-label>
    <ion-label range-right>10</ion-label>
  </ion-range>

Anyone got an idea?

like image 537
Rens Groenveld Avatar asked Nov 21 '16 21:11

Rens Groenveld


People also ask

What is the end range for ionic?

SE RWD (Standard Range): MPGe 127 City/ 94 Hwy/110 combined MPGe and 220 mile driving range.

What is ion range slider?

shadow. The Range slider lets users select from a range of values by moving the slider knob. By default one knob controls the value of the range.

What is ion range?

The Ionic range slider is used to choose and display the level of values by moving the slider knob. By default, only one knob controls the value of the range, but it can also accept dual knobs.


1 Answers

The answer is right in the docs in the section output-events:

ionChange Expression to evaluate when the range value changes.

Use it as follows:

<ion-range min="0" max="10" color="danger" (ionChange)="myMethod($event)">
  <ion-label range-left>0</ion-label>
  <ion-label range-right>10</ion-label>
</ion-range>
like image 184
RomanHotsiy Avatar answered Sep 25 '22 22:09

RomanHotsiy