{ "id": "api/common/APP_BASE_HREF", "title": "APP_BASE_HREF", "contents": "\n\n
\n
\n
\n \n API > @angular/common\n
\n \n
\n \n
\n

APP_BASE_HREFlink

\n \n \n \n \n \n
\n \n \n\n
\n \n
\n

A predefined DI token for the base href\nto be used with the PathLocationStrategy.\nThe base href is the URL prefix that should be preserved when generating\nand recognizing URLs.

\n\n \n
\n \n \n \n \n const APP_BASE_HREF: InjectionToken<string>;\n \n\n \n\n \n \n\n \n
\n

Usage noteslink

\n

The following example shows how to use this token to configure the root app injector\nwith a base href value, so that the DI framework can supply the dependency anywhere in the app.

\n\nimport {Component, NgModule} from '@angular/core';\nimport {APP_BASE_HREF} from '@angular/common';\n\n@NgModule({\n providers: [{provide: APP_BASE_HREF, useValue: '/my/app'}]\n})\nclass AppModule {}\n\n\n
\n\n\n\n
\n
\n\n\n" }