Hi,

Pretty new to AngularJS, and was playing with the getterSetter 
functionality of ngModel. However, as noted in the issue, there's a problem 
distinguishing between setting an undefined value to the model and doing a 
get:

https://github.com/angular/angular.js/issues/768

e.g. try to delete the last bit of the name here:

http://plnkr.co/edit/nuPno2RhoZPji6k2NCJQ

This seems like a bit of an issue to me, but it may be I'm using these in 
the wrong manner.

My actual use case is to have an input box using degrees/minutes, but store 
the value 'under the hood' in decimal degrees (e.g. for Google Maps). To 
make this work, however, I have to not only allow invalid values (so 
undefined is never set on the model, since that fails) but also store the 
latest input value (so I don't overwrite it when the getter is called due 
to differing precisions). e.g.

          if (angular.isDefined(newVal)) {
            decimalDegrees = convFromDecMins(newVal);
            degreesMinutes = newVal;
          } else if (convFromDecMins(degreesMinutes) != decimalDegrees) {
            degreesMinutes = convToDecMins(s[variable]);
          }
          return degreesMinutes;

Seems a bit messy and confusing. Perhaps there's a better way to do this? I 
saw one blog post advocating watches on both sides. Yuk.

James.

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to