Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[[ng][directives]] OneTimeDirective #ng #directive
// https://github.com/angular/angular/issues/14033
@Directive({
selector: '[oneTime]',
})
export class OneTimeDirective {
constructor(template: TemplateRef<any>, container: ViewContainerRef, zone: NgZone) {
zone.runOutsideAngular(() => {
const view = container.createEmbeddedView(template);
setTimeout(() => view.detach());
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.