模块“AppModule"声明的意外值“未定义" [英] Unexpected value 'undefined' declared by the module 'AppModule'
本文介绍了模块“AppModule"声明的意外值“未定义"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这里有什么问题?我正在尝试使其工作,但在标题中出现该错误.我在 app.component.html
中包含了 <router-outlet></router-outlet>
被 templateUrl
调用通过 app.component.ts
,仍然没有运气.
What is wrong here? I'm trying to make it work but I get that error in the header. I have included the <router-outlet></router-outlet>
in the app.component.html
that is being templateUrl
called by the app.component.ts
, still no luck.
app.module.ts:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { RouterModule, Routes } from '@angular/router';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { TopnavComponent } from './components/navbars/topnav/topnav.component';
import { LeftnavComponent } from './components/navbars/leftnav/leftnav.component';
import { LeftnavsecondaryComponent } from './components/navbars/leftnav-secondary/leftnav-secondary.component';
import { WorldofwarcraftComponent } from './components/games/worldofwarcraft/worldofwarcraft.component';
@NgModule({
imports: [ BrowserModule, FormsModule, AppRoutingModule ],
declarations: [ AppComponent, TopnavComponent, LeftnavComponent, LeftnavsecondaryComponent, WorldofwarcraftComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
app-routing.module.ts:
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { WorldofwarcraftComponent } from './components/games/worldofwarcraft/worldofwarcraft.component';
const appRoutes: Routes = [
{ path: 'worldofwacraft', component: WorldofwarcraftComponent }
];
@NgModule({
imports: [ RouterModule.forRoot(appRoutes) ],
exports: [ RouterModule ]
})
export class AppRoutingModule {}
推荐答案
我遇到了同样的错误,有时会出现这个问题,您只需要使用 ng serve
或任何 CLI 重新运行服务器您使用,如此处
I got the same error , sometimes this issue occur and you only need to re-run the server using ng serve
or whatever CLI you use , as mentioned here
这篇关于模块“AppModule"声明的意外值“未定义"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文