I have the following prop in my data provider/service…
get Comparisons(): number[] {
if (this.data == null)
return [];
// console.log('PWCInputProvider------------>>Comparisons', r);
return this.data.HDM.Level[1].E[2].w;
}
Here is the html
<p>
Comparisons....
</p>
<ion-list>
<ion-item *ngFor="let w of PWCInputProvider.Comparisons; let i = index">
<ion-range min="0" max="100" pin="true" debounce="50" [(ngModel)]="PWCInputProvider.Comparisons[i]" >
<ion-label range-left class="small-text">Apples</ion-label>
<ion-label range-right>Oranges</ion-label>
</ion-range>
</ion-item>
</ion-list>
If I enable the console.log I will see a zillion calls to the Comparisons property while I try to move the slider (range) and it responds very very slowly and the pin won’t even display (not usable).
What am I doing wrong?
I would like the 2-way binding between the ranges and some corresponding model in my data provider class (an array of integers representing the latest values).
Comparisons_: number[] = [];
<ion-item *ngFor="let w of PWCInputProvider.Comparisons_; let i = index">
<ion-range min="0" max="100" pin="true" [(ngModel)]="PWCInputProvider.Comparisons_[i]" >
I added debounce attribute and tested various values, 50, 500, 1000 not change in super sluggish response.
I also tried in vain a simple field member in my provider as in:
If I remove the ngModel altogether I get a normal UI response, smooth sliding, pin pops, shows value and has an animation, but of course all ranges inserted in this manner are just vanilla, unbound and no initial value.
UPDATE
It appears as if inserting ranges via the ngFor is the problem. My current test data returns an array of 3 numbers, if I insert an instance of the range bound to the second element as below explicitly before the ngFor, then I get the following behavior. This first instance responds just fine to human interaction and also causes the 3rd instance to sync. However, all 3 instances of the range control inserted via the *nfFor do not respond. Should I report this as a bug?
<ion-range min="0" max="100" pin="true" [(ngModel)]="PWCInputProvider.Comparisons[1]">
<ion-label range-left class="small-text">Apples</ion-label>
<ion-label range-right>Oranges</ion-label>
</ion-range>
<ion-list>
<ion-item *ngFor="let w of PWCInputProvider.Comparisons; let i = index">
<ion-range min="0" max="100" pin="true" [(ngModel)]="PWCInputProvider.Comparisons[i]">
<ion-label range-left class="small-text">Apples</ion-label>
<ion-label range-right>Oranges</ion-label>
</ion-range>
</ion-item>
</ion-list>
Thank you.