8000 feat(change-detection): add bind-once support in templates · Issue #2449 · angular/angular · GitHub
[go: up one dir, main page]

Skip to content
feat(change-detection): add bind-once support in templates #2449
Closed
@jeffbcross

Description

@jeffbcross

@gdi2290 and I were just troubleshooting an issue related to an observable pipe always emitting a null value because the observable reference being passed into the pipe never matched the already set observable instance. This was because the template was calling a method to return an observable, causing a new observable to be created on each lifecycle tick.

{{ someService.getObservable() | async }}

It would be nice to have the same one-time binding capability as AngularJS 1.x where bindings could be expressed as "bind once" inside of templates.

One option is to create a pipe to support this, where as soon as a non-undefined value is returned from the left-side, the once pipe would cache and keep the reference:

{{ someService.getObservable() | once | async }}

Or we could add template sugar for this.

{{ ::someService.getObservable() | async}}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0