Allow binding to getter/setter fn
Now, when we have "accessor" locals, one should be able to bind to accessor. So either $parse or ng-model shoul handle it.
This is ugly - with binding to getter/setter, I wouldn't have to do the extra "value" and copying back and forward: http://jsfiddle.net/vojtajina/XuhzP/64/
The tpl of the component would be just:
<span ng-hide="editMode" ng-click="editMode=true">{{model()}}</span>
<input type="text" ng-model="model" ng-show="editMode" ng-enter="editMode=false" />
Another ugly solution (taking advantage of obj reference from parent scope): http://jsfiddle.net/vojtajina/XuhzP/65/
+1 this provides real encapsulation so that our models are clean.
+1 I really need this too - actually the getter more than the setter, but both would be handy.
+1 any solutions?
+1 for getter and setter as ng-model
+1
+1 es5 get/set work, but for ng-model we need a solution
+1
+1
+1
+1
:+1:
+1
+1
+1 here as well. I have been using Angular for just a short period of time, and I am already hitting this limitation. My use case is that I have a backend service returning a JSON that has very minimal, generic values, which must be compared against a core data structure the app brings in from a service at run time. I then want to take my models and parse them through a wrapper function which does the following:
- compares the values of my model against their appropriate structures in core, returning readable, view-ready values
- provides a public API for get/set the model data against core
So my wrapper object would perform all operations on the actual model, angular would only be responsible for calling the public API instead of working directly on my model, but still retain the ability to bind to data.
Ultimately, the point is that all of this parsing could be handled on the backend at the time we a GET or POST is received, but, we're talking about Client-side SPA frameworks here - shouldn't we move that work into the client's browser? Why should my precious little server have to work so hard if the users browser can do it themselves? :)
:+1:
+1
I would love a solution that is flexible enough to handle mori (Clojure immutable data structures ported to JS) or ProtoBuf.js in addition to standard getter/setters.
In particular, mori's immutable data structures would probably make change detection very efficient.
+1
+1
+1