我一直收到以下错误:
Failed to load resource: the server responded with a status of 404 (Not Found)
zone.js:461 Unhandled Promise rejection: Error: XHR error (404 Not Found) loading http://localhost:4200/app.routes
at XMLHttpRequest.wrapFn [as _onreadystatechange] (http://localhost:4200/vendor/zone.js/dist/zone.js:769:30)
at ZoneDelegate.invokeTask (http://localhost:4200/vendor/zone.js/dist/zone.js:356:38)
at Zone.runTask (http://localhost:4200/vendor/zone.js/dist/zone.js:256:48)
at XMLHttpRequest.ZoneTask.invoke (http://localhost:4200/vendor/zone.js/dist/zone.js:423:34)
Error loading http://localhost:4200/app.routes as "./app.routes" from http://localhost:4200/main.js ; Zone: <root> ; Task: Promise.then ; Value: Error: Error: XHR error (404 Not Found) loading http://localhost:4200/app.routes(…)consoleError @ zone.js:461
zone.js:463 Error: Uncaught (in promise): Error: Error: XHR error (404 Not Found) loading http://localhost:4200/app.routes(…)
这是我的app.routes.ts:
import { Routes, RouterModule } from '@angular/router';
import { AppComponent } from './app/app.component'
import { CreateServiceComponent } from './app/createservice/createservice.component'
const appRoutes: Routes = [
//{ path: 'crisis-center', component: CrisisCenterComponent },
{ path: 'services/create', component: CreateServiceComponent },
{ path: '/', component: AppComponent }
//{ path: '**', component: PageNotFoundComponent }
];
export const appRoutingProviders: any[] = [
];
export const routing = RouterModule.forRoot(appRoutes);
和我的主要内容:
@NgModule({
imports: [
BrowserModule,
AngularFireModule.initializeApp(firebaseConfig),
RouterModule,
routing
],
declarations: [ AppComponent, CreateServiceComponent ],
providers: [ appRoutingProviders ],
bootstrap: [ AppComponent,FIREBASE_PROVIDERS ]
})
export class MyAppModule {}
if (environment.production) {
enableProdMode();
}
bootstrap(AppComponent, [
FIREBASE_PROVIDERS,
defaultFirebase(firebaseConfig),
firebaseAuthConfig({
provider: AuthProviders.Facebook,
method: AuthMethods.Popup
})]);
答案 0 :(得分:0)
您将rc4逻辑与rc5逻辑相结合......
NgModule
附带rc5,但您使用的引导方法仍然是rc4。
您需要更改将应用程序引导到以下内容的方式:
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
// or wherever your AppModule lives
import AppModule from './app/app.module';
platformBrowserDynamic().bootstrapModule(AppModule);
答案 1 :(得分:0)
似乎是app.routes文件的路径问题,localhost:4200 / app.routes,您是否检查过该位置是否存在该文件?