Hide on prod - Angular Directive
Lukasz Kuklis
Posted on December 25, 2021
*hideOnProd directive
import { Directive, ViewContainerRef, OnInit, TemplateRef } from '@angular/core';
import { environment } from 'path/to/environments/environment';
@Directive({
selector: '[hideOnProd]'
})
export class HideOnProdDirective implements OnInit{
constructor(private templateRef: TemplateRef<any>, private viewContainerRef: ViewContainerRef) { }
ngOnInit(): void {
if(environment.production == false){
this.viewContainerRef.createEmbeddedView(this.templateRef);
}
}
}
đ đȘ đ
đ©
Lukasz Kuklis
Posted on December 25, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.