に取り組んでいない私は、次のルートの設定とNgModule app.module.tsでAngularCliアプリケーションルートは生産
アプリ-routing.module.tsオンimport { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { OneComponent } from './components/one.component';
import { TwoComponent } from './components/open/two.component';
const routes: Routes = [
{ path: '', redirectTo: 'one', pathMatch: 'full' },
{ path: 'one', component: OneComponent },
{ path: 'two', component: TwoComponent },
{ path: '**', redirectTo: 'one' }
];
@NgModule({
imports: [RouterModule.forRoot(routes, { useHash:false })],
exports: [RouterModule]
})
export class AppRoutingModule { }
とAngularCliとの角度のアプリを持っている
import { LocationStrategy, PathLocationStrategy } from '@angular/common';
@NgModule({
declarations: [
AppComponent,
OneComponent,
TwoComponent
]
imports: [
AppRoutingModule,
],
bootstrap: [AppComponent],
providers: [{ provide: LocationStrategy, useClass: PathLocationStrategy }]
})
開発モードではルートは問題ありませんが、本番用に行くと(ng build --prod --aot)ルートが機能しなくなります。 私がHashLocationStrategyルートを使用する場合は、開発モードと運用モードの両方で動作しますが、時にはURLを2〜3回ヒットする必要があるため、いくつかの問題があります。
PathLocationStrategyが私に私が欲しいと思う行動だけではなく、開発と生産ではない。
は、私はあなたがIISでWebアプリケーションをデプロイしている場合、事前
開発モードでアプリをどのように構築して使用していますか? ng serve -oを使用していますか?いつものようにdev(ng serve)の – RRForUI
。デプロイメント(ng build --prod --aot) –