我有一个Angular应用程序。我运行命令
ng build --prod --aot
以生成
dist文件夹。在dist文件夹中,我创建了一个名为
Staticfile的文件,然后使用以下命令将dist文件夹上传到
pivotal.io:
- cf push name-app --no-start
- cf start name-app
该应用程序运行良好。我有一个导航栏,所以当我使用导航栏更改路径时一切正常。但是当我手动更改URL(自己输入URL)时,出现404 Not Found nginx错误。这是我的app.component.ts:
const appRoutes: Routes = [
{ path: 'time-picker', component: TimePickerComponent },
{ path: 'material-picker', component: MaterialPickerComponent },
{ path: 'about', component: AboutComponent },
{ path: 'login', component: LoginComponent },
{ path: 'registration', component: RegistrationComponent },
{
path: '',
redirectTo: '/time-picker',
pathMatch: 'full'
}
];
@NgModule({
declarations: [
AppComponent,
TimePickerComponent,
MaterialPickerComponent,
DurationCardComponent,
AboutComponent,
LoginComponent,
RegistrationComponent,
],
imports: [RouterModule.forRoot(
appRoutes
),
FormsModule,
BrowserAnimationsModule,
BrowserModule,
MdCardModule, MdDatepickerModule, MdNativeDateModule, MdInputModule
],
providers: [{ provide: DateAdapter, useClass: CustomDateAdapter }],
bootstrap: [AppComponent]
})
export class AppModule {
constructor(private dateAdapter: DateAdapter<Date>) {
this.dateAdapter.setLocale('fr-br');
}
}