在我简单的NG2 SPA中,除了“/”
之外,我导航的所有内容都会抛出404。index.html(摘录)
<html>
<head>
<base href="/">
<!-- lots of script tags -->
<script src="systemjs.config.js"></script>
<script>
System.config({
packages: {app: {format: 'register',defaultExtension: 'js'}}
});
System.import('app/main')
.catch(function(err){ console.error(err); });
</script>
</head>
<body>
<my-foo>Loading...</my-foo>
</body>
</html>
应用程序/ main.ts
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';
platformBrowserDynamic().bootstrapModule(AppModule);
应用程序/ app.module.ts
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { MeetingComponent } from './meeting.component';
import { routing } from './app.router';
@NgModule({
imports: [ BrowserModule, FormsModule, routing ],
declarations: [ AppComponent, MeetingComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
应用程序/ app.component.ts
import { Component, Input } from '@angular/core';
import { MeetingComponent } from './meeting.component';
@Component({
selector: 'my-foo',
template: `
<h1>Hello World</h1>
<router-outlet></router-outlet>
`
})
export class AppComponent {}
应用程序/ app.router.ts
import { RouterModule } from "@angular/router";
import { MeetingComponent } from './meeting.component';
export const routes = [
{path:"", component: MeetingComponent},
{path:"foo", component: MeetingComponent},
{path:"meeting", component: MeetingComponent}
];
export const routing = RouterModule.forRoot(routes);
meeting.component.ts
import { Component, Input } from '@angular/core';
@Component({
selector: 'my-meeting',
template: `<div>I'm the meeting component</div>`
})
export class MeetingComponent {}
现在我应该能够导航到localhost:3000,localhost:3000 / foo或localhost:3000 / meeting,并且所有人都可以使用相同的东西。但只有localhost:3000出现。其他网址正在抛出404s
对于DEITY的爱...为什么?!?