[英]Uncaught (in promise): Error: No NgModule metadata found for '[object Object]'
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { RouterModule } from '@angular/router';
import { LoginComponent } from './login.component';
export const routes=[
{ path:'',component:LoginComponent }
];
@NgModule({
imports: [
CommonModule,
HttpModule,
FormsModule,
RouterModule.forChild(routes)
],
declarations: [
LoginComponent
],
})
export default class Login {
static routes = routes;
}
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './home';
export const appRoutes: Routes = [
{ path:'',component:HomeComponent },
{ path:'login',loadChildren: ()=>System.import("./+login")}
];
EXCEPTION: Uncaught (in promise): Error: No NgModule metadata found for '[object Object]'.
例外:未发现(承诺):错误:找不到“ [对象对象]”的NgModule元数据。 ac_vendor<["./node_modules/@angular/compiler/src/ng_module_resolver.js"]/NgModuleResolverhttp://127.0.0.1:3000/vendor.bundle.js:13839:23
ac_vendor <[ “./node_modules/@angular/compiler/src/ng_module_resolver.js”] /NgModuleResolverhttp://127.0.0.1:3000/vendor.bundle.js:13839:23
This problem plagued me for a long time, please help me 这个问题困扰了我很长时间,请帮帮我
I had the same problem after upgrading from Angular 2.0.x to Angular 4.0.x Problem was in the syntax of Routes. 从Angular 2.0.x升级到Angular 4.0.x之后,我遇到了同样的问题。问题出在Routes的语法中。 You need to specify the NgModule that is responsible for display of child page.
您需要指定负责显示子页面的NgModule。
Old syntax: { path: 'jobs', loadChildren: () => System.import('./jobs/jobs.module') }
旧语法:
{ path: 'jobs', loadChildren: () => System.import('./jobs/jobs.module') }
New syntax: { path: 'jobs', loadChildren: 'app/pages/jobs/jobs.module#JobsModule' }
新语法:
{ path: 'jobs', loadChildren: 'app/pages/jobs/jobs.module#JobsModule' }
(note the #JobsModule at the end) (请注意最后的#JobsModule )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.