3
在之前的rc.4版本中,設置hashbang#!看起來像這樣Angular2 rc.5和hashbang
bootstrap(ApplicationComponent, [....
{provide: LocationStrategy, useClass: HashLocationStrategy},
{provide: APP_BASE_HREF, useValue: '!'}
]);
現在在rc.5中一切都變了一點點,我努力找到一種方法來擁有包含#的相同地址!
Angular docs對於設置路由非常明確,但hashbang在描述中有些跳過(https://angular.io/docs/ts/latest/guide/router.html)。單獨設置散列像這樣在rc.5 app.routing.ts
export const routing = RouterModule.forRoot(appRoutes, { useHash: true });
但不知道如何額外定義做了「!」在URL 5在rc.5
我不知道它應該如何應用和以什麼形式。也許在boostrap:...裏面的@NgModule在app.module中,但到目前爲止我沒有使它工作。請建議。
非常感謝你做這樣的
app.module.ts
文件。我以爲我已經嘗試過了,但又多投了一槍,一切都很好。謝謝。 –