You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
The expression in ng-model directive is evaluated always, even if it is prefixed with ::, which is the correct and reasonable behavior. Anyway, when ng-model-options is present and getterSetter is true, one-time binding could be profitably honored, especially if the model expression evaluates to a getter-setter factory function.
Minimal demo of the problem
Demo. By opening the console, one can see that the ng-model expression is not evaluated once.
What is the expected behavior?
When ng-model-options is present (directly or by inheritance from parent elements) and getterSetter is true, honor one-time binding if specified in the ng-model expression.
What is the motivation / use case for changing the behavior?
In the given conditions, the expression returns a function that may or may not change. If it does not change, the overhead of evaluating it every time can be removed. Moreover, if such getter-setter function has some context to be preserved from call to call, one-time binding would remove the need to manually cache it.
The text was updated successfully, but these errors were encountered:
I am not sure how much work it requires (because the current implementation expects the ng-model expression to be a direct reference to a function). It is probably not worth it imo (considering it won't be a trivial change).
As a work-around, you can achieve a similar behavior by using ngInit to initialize the getterSetterFn:
@Thaina, of course it will conflict if you use the same variable name on the same scope. It is trivial to create your own version of ngInit that also creates a new scope, but the simplest thing to do here is use a unique variable name:
BTW, this is not related to this issue, because the name conflict would be present regardless if one-time binding is supported for getterSetter in ngModel or not.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Do you want to request a feature or report a bug?
Feature.
What is the current behavior?
The expression in
ng-model
directive is evaluated always, even if it is prefixed with::
, which is the correct and reasonable behavior. Anyway, whenng-model-options
is present andgetterSetter
istrue
, one-time binding could be profitably honored, especially if the model expression evaluates to a getter-setter factory function.Minimal demo of the problem
Demo. By opening the console, one can see that the
ng-model
expression is not evaluated once.What is the expected behavior?
When
ng-model-options
is present (directly or by inheritance from parent elements) andgetterSetter
istrue
, honor one-time binding if specified in theng-model
expression.What is the motivation / use case for changing the behavior?
In the given conditions, the expression returns a function that may or may not change. If it does not change, the overhead of evaluating it every time can be removed. Moreover, if such getter-setter function has some context to be preserved from call to call, one-time binding would remove the need to manually cache it.
The text was updated successfully, but these errors were encountered: