Hey guys I just wanted to create a form which uses a range from 1-5 but when i want to access the value it is undefined.
Do u know what i am doing wrong?
Code:
<form (ngSubmit)="logForm()">
<!-- Testfall 1 (1-5) -->
<ion-item>
<ion-label text-wrap>Das ist eine sehr lange Frage die sich nicht in einer Zeile ausgeht?</ion-label>
<ion-range min="1" max="5" step="1" snaps="true" color="secondary" id="kindofquestionOne_1">
<ion-label range-left>1</ion-label>
<ion-label range-right>5</ion-label>
</ion-range>
</ion-item>
</form>
<form (ngSubmit)="logForm()">
<!-- Testfall 1 (1-5) -->
<ion-item>
<ion-label text-wrap>Das ist eine sehr lange Frage die sich nicht in einer Zeile ausgeht?</ion-label>
<ion-range min="1" max="5" step="1" snaps="true" color="secondary" id="kindofquestionOne_1" (ionChange)="onChange($event)">
<ion-label range-left>1</ion-label>
<ion-label range-right>5</ion-label>
</ion-range>
</ion-item>
</form>
Set rangeValue to whatever you want. I used 1 because it’s your minimum value. And of course, name rangeValue whatever you want too.
@flycoders_sourav had the right idea with ionChange, but you can leave the event reference out of the picture and just console.log this.rangeValue in the function.
thx for ur answer!
It seems to be a really nice solution, but to be honest, this is my first application with ionic and angular js and cause of that i have really little knowledge about ng-model.
How can i connect your code with my ion-range?
Glad it worked out. I’d suggest going through https://angular.io
and at the least, do the hall of heroes tutorial. I waited until I had been programming for a year and a half to do so and I’m kicking myself for it. Fantastic documentation.