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
I'll work on this.
+1
Just to be clear this issue is about improving the way we databind to getter/setters implemented via jQuery style methods.
A good example of this api is $location.path which when called as $location.path() functions as a getter and when called as $location.path(newValue) functions as a setter.
The problem we have is that if we just considered all functions to be getters/setters by default we would lose access to function references. So for this reason we can't implement uniform access within the expression language.
One potential solution is to implement this only for ngModel:
<input ng-model="$location.path(newNgModelValue)">
or just:
<input ng-model="$location.path()">
Might be worth noting that we represent invalid value as undefined in ngModel, which is the same as the getter style call for jquery getters - how can we disambiguate that?
On Montag, 7. April 2014 13:42:53, Igor Minar [email protected] wrote:
Just to be clear this issue is about improving the way we databind to getter/setters implemented via jQuery style methods.
A good example of this api is $location.path which when called as $location.path() functions as a getter and when called as $location.path(newValue) functions as a setter.
The problem we have is that we we just considered all functions to be getters/setters by default we would lose access to function references. So for this reason we can't implement uniform access within the expression language.
One potential solution is to implement this only for ngModel:
or just:
Reply to this email directly or view it on GitHubhttps://github.com/angular/angular.js/issues/768#issuecomment-39780740 .
Closed via b9fcf017316d37e91959949f56692644ce09d54a.
Sweet! That's great, thanks a lot :)