Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Allow one-time binding for ng-model when ng-model-options getterSetter is true #15643

Open
@FstTesla

Description

@FstTesla

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, 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions