In my deployment process, we have different environments - dev and prod. Therefore, we have eG various Api Urls and other things that need to be configured. Since I use the Angular 2 CLI, there are environment files.
To access the configuration files, my first idea was to create a service that receives environment files and reads properties. The service is then provided so that any component can access it.
import { Injectable } from '@angular/core';
import { environment } from '../../../environments/environment';
@Injectable()
export class UtilService {
constructor() { }
}
Is there a better approach than using a service? I do not want to import environment files into each component.
source
share