填寫這份《一分鐘調查》,幫我們(開發組)做得更好!去填寫Home

APP_BASE_HREF

預定義的 DI 令牌,用於和 PathLocationStrategy 一起使用的 base href。base href 是在產生和識別 URL 時應保留的 URL 字首。

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>;
    

使用說明

以下示例示範瞭如何使用此令牌為基本應用注入器配置 base href 值,以便 DI 框架可以在應用中的任何位置提供依賴項。

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 {}