Angular2 rc.5和hashbang

Angular2 rc.5和hashbang,angular,angular2-routing,hashbang,Angular,Angular2 Routing,Hashbang,在以前的rc.4版本中,设置hashbang#!像这样 bootstrap(ApplicationComponent, [.... {provide: LocationStrategy, useClass: HashLocationStrategy}, {provide: APP_BASE_HREF, useValue: '!'} ]); 现在在rc.5中,一切都发生了一点变化,我很难找到一种方法让相同的地址包含# Angular文档非常清楚如何设置路由,但在tha descr

在以前的rc.4版本中,设置hashbang#!像这样

bootstrap(ApplicationComponent, [....
    {provide: LocationStrategy, useClass: HashLocationStrategy},
    {provide: APP_BASE_HREF, useValue: '!'}
]);
现在在rc.5中,一切都发生了一点变化,我很难找到一种方法让相同的地址包含#

Angular文档非常清楚如何设置路由,但在tha description()中略过了hashbang。在rc.5 app.routing.ts中,单独设置哈希是这样做的

export const routing = RouterModule.forRoot(appRoutes, { useHash: true });
但是,我不知道如何在rc.5的url中另外定义“!”


我不知道该如何应用,以何种形式应用。也许在boostrap中:。。。在app.module中的@NgModule内,但到目前为止,我没有使其工作。请建议。

您可以在
app.module.ts
文件中这样做,方法是将其添加到
提供者
数组中

import {ReflectiveInjector} from '@angular/core';
import { Http, Response, Request, HTTP_PROVIDERS } from '@angular/http';

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

@NgModule({
  imports: [
    BrowserModule,
    FormsModule,
    routing,

  ],
  declarations: [
    AppComponent,
    MyComponent,
  ],
  bootstrap: [
    AppComponent
  ],
  providers: [
    {provide:AuthService,useValue:authService}, // over here
    AdminAuthGuard,
    UserAuthGuard
  ]
})

非常感谢你。我以为我已经试过了,但又试了一次,一切都很好。谢谢