1 | initial version |
Angular 15 does not exist. The latest version of Angular as of May 2021 is version 12. However, to set the base href
in Angular, you can add it to the index.html
file like so:
<base href="/your-base-href/">
Or, you can use the APP_BASE_HREF
provider in your app module to specify the base href programmatically.
In your app.module.ts
, import the APP_BASE_HREF
token and set its value to your desired base href:
import { NgModule } from '@angular/core';
import { APP_BASE_HREF } from '@angular/common';
@NgModule({
providers: [
{ provide: APP_BASE_HREF, useValue: '/your-base-href/' }
]
})
export class AppModule { }
This will set the base href
for your entire Angular application. Note that when using ng serve
, any changes made to index.html
will be hot-reloaded, but changes to app.module.ts
will require a server restart.