[[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