Skip to content

Instantly share code, notes, and snippets.

@gparlakov
Created October 10, 2021 17:57
Show Gist options
  • Select an option

  • Save gparlakov/6b06e46cfbf036a0b4fcb85f93492c6c to your computer and use it in GitHub Desktop.

Select an option

Save gparlakov/6b06e46cfbf036a0b4fcb85f93492c6c to your computer and use it in GitHub Desktop.
Naive implementation of ifFeatureFlagDirective
@Directive({
selector: '[ifFeature]',
})
export class IfFeatureFlagDirective<IfTemplate, ElseTemplate> {
// assume flags, viewContainerRef, TemplateRef ...
@Input('ifFeature')
set ifFeature(f: string) {
if(this.flags[f]) {
this.viewContainerRef.createEmbeddedView(this.template);
} else {
this.viewContainerRef.clear();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment