APP_BASE_HREF

The APP_BASE_HREF token represents the base href to be used with the PathLocationStrategy.

查看"说明"...

      
      const APP_BASE_HREF: InjectionToken<string>;
    

说明

If you're using PathLocationStrategy, you must provide a provider to a string representing the URL prefix that should be preserved when generating and recognizing URLs.

使用说明

Example

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