ngModelOption's getterSetter does not work with Factory objects #9394
Description
Overview of the Issue
When using ng-model-options="{ getterSetter: true }"
, the getter & setter methods do not run within the correct scope if defined in a factory. This causes this
to be undefined
within the getter & setter method - preventing anything from being set or retrieved. (TypeError: Cannot read property 'x' of undefined
)
Motivation for or Use Case
While some getter & setter methods should be defined within the controller & scope - more complex objects should contain their own getter and setter methods defined within their factories for a better separation of concerns.
Angular Version
I've tried this with 1.3.0-rc.4
& 1.3.0-rc.3
Browsers and Operating System
This appears to be Angular.js specific and not a browser problem. However, I am using chrome 37.0.2062.124 m
on windows 7 64bit.
Reproduce the Error
Here is a plunker that has getter & setter methods defined within a object from a factory that does not work: http://plnkr.co/edit/RmoegMYEgF9s7s50KQNj?p=preview
Here is another version that has the object defined within the controller (no factory) that works fine: http://plnkr.co/edit/4f8i384nsRwCoaQtPoxx?p=preview