I am using different environments in angular, stored into the environments folder, like:
environment.ts
environment.dev.ts
environment.prod.ts
In the environment.ts file, I have:
export const environment = {
production: false,
environment: 'Development',
advanced: {
features: true
}
};
I want to show a div element in page only if the environment has this advanced feature equal to true. I was thinking of doing :
import { environment } from './environments/environment';
export class AdvancedComponent implements OnInit {
advancedFeatures:boolean;
constructor() { }
ngOnInit() {
this.advancedFeatures= environment.advanced.features;
if (this.advancedFeatures){
console.log("true");
}
else {
console.log('false');
}
}
}
Is this enough for hiding or showing a div element if the environment is dev or prod? Is this a good approach of the advanced feature from environment or should I somehow import all environments into this class?