Created
February 13, 2018 21:59
-
-
Save xperiments/07c72f8dc128435dff6157ca0ba4ffc7 to your computer and use it in GitHub Desktop.
[[ng][directives]] OneTimeDirective #ng #directive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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