如何使用hashbang?

uzh*_*has 0 angular

我想在角度路线中使用哈希.我试图找到,但所有的例子都是最老的版本.任何建议我怎么能这样做?

我试过这个:

let injector = ReflectiveInjector.resolveAndCreate(NgModule);
let http = injector.get(Http);
let authService = new AuthService(new LocalStorage(), http);

  providers: [ {provide:AuthService,useValue:authService}, // over here 
    SharedService,DatePipe],
Run Code Online (Sandbox Code Playgroud)

但我得到错误:

找不到本地存储,找不到AuthService,我不能在ReflectiveIncjector中使用NgModule.

任何建议我怎么能使用hashbang?

eko*_*eko 7

@NgModule你的使用中useHash:true:

imports: [
     RouterModule.forRoot([
       ...
      ]
      ,{ useHash: true }
  )],
Run Code Online (Sandbox Code Playgroud)

资料来源:https://angular.io/docs/ts/latest/guide/router.html#!#-hashlocationstrategy-

  • 但这不是hashbang`#!` (3认同)