Does anyone know how to accomplish this with the angular-cli? I would like to be able to store the baseHref
path in an environment variable within /src/envir
You would have to use APP_BASE_HREF
@NgModule({
providers: [{provide: APP_BASE_HREF, useValue: environment.baseHref }]
})
class AppModule {}
See angular doc
EDIT
Since CSS/JS does not work with APP_BASE_HREF, you can do this:
In app.component.ts, inject DOCUMENT via import {DOCUMENT} from "@angular/platform-browser";
constructor(@Inject(DOCUMENT) private document) {
}
Then on your ngOnInit()
ngOnInit(): void {
let bases = this.document.getElementsByTagName('base');
if (bases.length > 0) {
bases[0].setAttribute('href', environment.baseHref);
}
}