これは以下のフォローアップAngular 2.0 router not working on reloading the browser 私はHashLocationStrategyを使用するようにルータを設定しても、まだ#を使わずにURLパスを取得します。私は正確にAngular2ドキュメントhttps://angular.io/docs/ts/latest/tutorial/toh-pt5.html に従うと説明した場所戦略を設定し、ここでhttps://angular.io/docs/ts/latest/guide/router.htmlAngular2ルーティングno HashLocationStrategyでもハッシュ
私のブートストラップ:
import {bootstrap} from 'angular2/platform/browser';
import {provide} from 'angular2/core';
import {
ROUTER_PROVIDERS,
LocationStrategy,
HashLocationStrategy
} from 'angular2/router';
import {AppComponent} from './app.component';
bootstrap(AppComponent, [
ROUTER_PROVIDERS,
provide(LocationStrategy, { useClass: HashLocationStrategy })
]);
とルータの設定:
@RouteConfig([
{
path: '/detail/:id',
name: 'HeroDetail',
component: HeroDetailComponent
},
{
path: '/heroes',
name: 'Heroes',
component: HeroesComponent
},
{
path: '/dashboard',
name: 'Dashboard',
component: DashboardComponent,
useAsDefault: true
}
])
私が見ることを期待したいですURLはhttp://localhost/#/dashboardですが、http://localhost/dashboardとなります。 私は何が欠けていますか?
削除_useAsDefault_が最初のリダイレクトを削除しますが、私の問題を解決していません。 – Gregor