我想在角度路线中使用哈希.我试图找到,但所有的例子都是最老的版本.任何建议我怎么能这样做?
我试过这个:
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?
在@NgModule你的使用中useHash:true:
imports: [
RouterModule.forRoot([
...
]
,{ useHash: true }
)],
Run Code Online (Sandbox Code Playgroud)
资料来源:https://angular.io/docs/ts/latest/guide/router.html#!#-hashlocationstrategy-
| 归档时间: |
|
| 查看次数: |
2691 次 |
| 最近记录: |