Issue
How to get APP_BASE_HREF programmatically?
I have this in my app.module.ts (where APP_BASE='/'):
{
provide: APP_BASE_HREF,
useValue: '<%= APP_BASE %>'
},
I'm trying:
import { APP_BASE_HREF } from '@angular/common';
...
console.debug(APP_BASE_HREF.toString());
and in console I get:
Token appBaseHref
and I need to get:
http://localhost:5555/
Solution
Just inject it to a service or component like
import { APP_BASE_HREF } from '@angular/common';
...
constructor(@Inject(APP_BASE_HREF) private baseHref:string) {
console.log(this.baseHref);
}
Answered By - Günter Zöchbauer
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.