填写这份《一分钟调查》,帮我们(开发组)做得更好!去填写Home

APP_BASE_HREF

A predefined DI token for the base href to be used with the PathLocationStrategy. The base href is the URL prefix that should be preserved when generating and recognizing URLs.

      
      const APP_BASE_HREF: InjectionToken<string>;
    

使用说明

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

import {Component, NgModule} from '@angular/core'; import {APP_BASE_HREF} from '@angular/common'; @NgModule({ providers: [{provide: APP_BASE_HREF, useValue: '/my/app'}] }) class AppModule {}
      
      import {Component, NgModule} from '@angular/core';
import {APP_BASE_HREF} from '@angular/common';

@NgModule({
  providers: [{provide: APP_BASE_HREF, useValue: '/my/app'}]
})
class AppModule {}