This content originally appeared on DEV Community and was authored by Lukasz Kuklis
*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);
}
}
}
This content originally appeared on DEV Community and was authored by Lukasz Kuklis
Print
Share
Comment
Cite
Upload
Translate
Updates
There are no updates yet.
Click the Upload button above to add an update.
APA
MLA
Lukasz Kuklis | Sciencx (2021-12-25T15:19:00+00:00) Hide on prod – Angular Directive. Retrieved from https://www.scien.cx/2021/12/25/hide-on-prod-angular-directive/
" » Hide on prod – Angular Directive." Lukasz Kuklis | Sciencx - Saturday December 25, 2021, https://www.scien.cx/2021/12/25/hide-on-prod-angular-directive/
HARVARDLukasz Kuklis | Sciencx Saturday December 25, 2021 » Hide on prod – Angular Directive., viewed ,<https://www.scien.cx/2021/12/25/hide-on-prod-angular-directive/>
VANCOUVERLukasz Kuklis | Sciencx - » Hide on prod – Angular Directive. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/12/25/hide-on-prod-angular-directive/
CHICAGO" » Hide on prod – Angular Directive." Lukasz Kuklis | Sciencx - Accessed . https://www.scien.cx/2021/12/25/hide-on-prod-angular-directive/
IEEE" » Hide on prod – Angular Directive." Lukasz Kuklis | Sciencx [Online]. Available: https://www.scien.cx/2021/12/25/hide-on-prod-angular-directive/. [Accessed: ]
rf:citation » Hide on prod – Angular Directive | Lukasz Kuklis | Sciencx | https://www.scien.cx/2021/12/25/hide-on-prod-angular-directive/ |
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.