Skip to content

Instantly share code, notes, and snippets.

@tjoskar
tjoskar / stream-context.directive.ts
Last active August 29, 2021 04:33
How to use observables in angular 2 template
import { Directive, Input, TemplateRef, ViewContainerRef, EmbeddedViewRef, ChangeDetectorRef } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Subscription } from 'rxjs/Subscription';
@Directive({
selector: '[streamContext][streamContextOn]'
})
export class StreamContext {
@Input() streamContextOn: Observable<any>;
templateRef: TemplateRef<any>;