작동하지 app.module.tsAngularCli 앱 노선 내가 앱 routing.module.ts에 다음과 같은 경로 구성 및 NgModule</p> <p>와 AngularCli과 각도 응용 프로그램을 생산
에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 { }
import { LocationStrategy, PathLocationStrategy } from '@angular/common';
@NgModule({
declarations: [
AppComponent,
OneComponent,
TwoComponent
]
imports: [
AppRoutingModule,
],
bootstrap: [AppComponent],
providers: [{ provide: LocationStrategy, useClass: PathLocationStrategy }]
})
개발 모드에서는 경로가 정상이지만 생산을 위해 갈 때 (ng 빌드 --prod - aot) 경로가 작동을 멈 춥니 다. HashLocationStrategy 경로를 사용하면 개발 및 프로덕션 모드를 모두 사용할 수 있지만 가끔씩 URL을 두 번 또는 세 번 눌러 내 Rest Api에 연결할 URL을 변경해야하기 때문에 몇 가지 문제가 발생합니다.
PathLocationStrategy가 제공하는 점은 내가 원하는 행동이지만, 개발에만 의존하고 생산에는 그렇지 않다.
난 당신이 IIS에서 웹 응용 프로그램을 배포 한 경우 사전
개발 모드에서 앱을 어떻게 만들고 사용하고 있습니까? 같이, 봉사를 사용합니까? 평소와 같이 dev (ng serve)에 대해서는 – RRForUI
입니다. 배포 (ng 빌드 --prod - aot) –