I'm using angular-cli's environment variables in a module. When I import my module in another project, is it possible to use my project's environment variables at compilation and runtime ?
My module
myModule/
src/
/app
my.service.ts
/environments
environment.prod.ts
environment.ts
app.module.ts
etc.
My module's my.service.ts
import { environment } from './environments/environment';
@Injectable()
export class MyService {
private title = environment.title;
showTitle(): string {
return this.title;
}
etc.
}
My module's environment.ts
export const environment = {
production: false,
title: 'My Module in dev mode'
}
My module's environment.prod.ts
export const environment = {
production: true,
title: 'My Module in prod mode'
}
My project
myProject/
src/
/app
app.component.ts
/environments
environment.prod.ts
environment.ts
app.module.ts
etc.
My project's AppComponent
Component({
selector: 'app-root',
template: `<h1>{{title}}</h1>`
})
export class AppComponent {
title: string;
constructor(myService: MyService) {
this.title = myService.showTitle();
}
}
My project's environment.ts
export const environment = {
production: false,
title: 'My Project in dev mode'
}
My project's environment.prod.ts
export const environment = {
production: true,
title: 'My Project in prod mode'
}
Currently, when I run my project, I see My Module in dev mode, but I'd want to see My Project in dev mode.
Is there a way to import environment.ts from a relative url like import { environment } from '/src/my-app/environments/environment' ?