Working with ng-model and input-type=range


#1

I guess this is more of a angular problem than ionic.
Here’s a codepen trying to explain the problem I’m facing : http://codepen.io/kazekagegaara/pen/CAkDd

No matter what number I select, my model doesn’t seem to get updated.
This issue has already been raised on Angular’s github : https://github.com/angular/angular.js/issues/1189 & https://github.com/angular/angular.js/issues/5892

Let me know if anyone knows a temporary hack for this.


#2

You need to use dot notation. When you just use “numberSelection”, you do not get 2 way binding. You get simple inheritance.

Here is a working example.


Issue with model binding when using ionic
#3

@Calendee Thanks. Could you just elaborate a little on why did you define the model as data.numberSelection? And should I always define models like this?


#4

It all comes down to prototypal inheritance. This is the definitive resource on the subject : https://github.com/angular/angular.js/wiki/Understanding-Scopes

Short Answer : Yes, mostly, almost always


#5

problem with dot notation is it doesn’t initialize :frowning: what is a workaround for this