Cookies concent notice

This site uses cookies from Google to deliver its services and to analyze traffic.
Learn more
Skip to main content
This site is no longer updated.Head to Angular.devHome
/

This is the archived documentation for Angular v17. Please visit angular.dev to see this page for the current version of Angular.

outputFromObservable

Declares an Angular output that is using an RxJS observable as a source for events dispatched to parent subscribers.

See more...

      
      outputFromObservable<T>(observable: Observable<T>, opts?: OutputOptions): OutputRef<T>
    
Parameters
observable Observable<T>
opts OutputOptions

Optional. Default is undefined.

Returns

OutputRef<T>

Description

The behavior for an observable as source is defined as followed:

  1. New values are forwarded to the Angular output (next notifications).
  2. Errors notifications are not handled by Angular. You need to handle these manually. For example by using catchError.
  3. Completion notifications stop the output from emitting new values.

Further information is available in the Usage Notes...

Usage notes

Initialize an output in your directive by declaring a class field and initializing it with the outputFromObservable() function.

      
      @Directive({..})
export class MyDir {
  nameChange$ = <some-observable>;
  nameChange = outputFromObservable(this.nameChange$);
}