Skip to content

Instantly share code, notes, and snippets.

@fireflysemantics
Last active September 2, 2022 20:33
Show Gist options
  • Save fireflysemantics/5f6385b2b08d673be1cda5571f38882b to your computer and use it in GitHub Desktop.
Save fireflysemantics/5f6385b2b08d673be1cda5571f38882b to your computer and use it in GitHub Desktop.
@Directive({ selector: '[isReady]' })
export class ReadyDirective implements OnInit {
@Input('isReady') isReady: boolean;
constructor(
private templateRef: TemplateRef<void>,
private vcr: ViewContainerRef
) {}
ngOnInit() {
if (this.isReady) {
this.vcr.createEmbeddedView(this.templateRef);
}
if (!this.isReady) {
this.vcr.createComponent(SpinnerComponent);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment