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.
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.
2 Likes
@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?
It all comes down to prototypal inheritance. This is the definitive resource on the subject : Understanding Scopes · angular/angular.js Wiki · GitHub
Short Answer : Yes, mostly, almost always
problem with dot notation is it doesn’t initialize
what is a workaround for this