Angular 404找不到2条路线
我不断得到以下错误:Angular 404找不到2条路线,angular,angular2-routing,Angular,Angular2 Routing,我不断得到以下错误: 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 _onready
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(…)
还有我的主要任务:
@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
})]);
您正在将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);
您正在将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);
似乎是app.routes文件的路径问题,localhost:4200/app.routes,是否检查该文件是否存在于该位置?似乎是app.routes文件的路径问题,localhost:4200/app.routes,是否检查该文件是否存在于该位置?似乎是app.routes文件的路径问题,你检查了文件是否存在于该位置了吗?现在可以工作了,但似乎无法在任何地方获取路由器链接。当我在锚标记上使用[routerLink]时,继续获取模板错误。如果你想提交答案,我会接受,因为这是问题请添加相应的代码进行调查。为此提出了一个新问题,因为它是一个不同的问题,似乎是app.routes文件的路径问题,你检查了文件是否存在于该位置了吗?现在可以工作了,但似乎无法在任何地方获取路由器链接。当我在锚标记上使用[routerLink]时,继续获取模板错误。如果你想提交答案,我会接受的,因为这是问题请添加相应的代码进行研究。为此提出了一个新问题,因为这是一个不同的问题,当我执行此platformBrowserDynamic()时出错。bootstrapModule(MyAppModule)而不是我在这种情况下遇到的问题,我相信你有一个构建或配置问题。。。您需要将这些信息作为问题的一部分发布。当我执行此platformBrowserDynamic()时出现错误。bootstrapModule(MyAppModule)而不是我所拥有的。在这种情况下,我相信您存在生成或配置问题。。。您需要将该信息作为问题的一部分发布。我已将app.routes.ts文件移动到/app目录中,它可以正常工作!我将app.routes.ts文件移动到了/app目录,它可以工作了!