在AppComponent中,我在HTML代码中使用nav组件.用户界面看起来很好.做服务时没有错误.当我查看应用程序时,控制台中没有错误.
但是当我为我的项目运行Karma时,出现了一个错误:
Failed: Template parse errors:
'app-nav' is not a known element:
1. If 'app-nav' is an Angular component, then verify that it is part of this module.
2. If 'app-nav' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
Run Code Online (Sandbox Code Playgroud)
在我的app.module.ts中:
有:
import { NavComponent } from './nav/nav.component';
Run Code Online (Sandbox Code Playgroud)
它也在NgModule的声明部分
@NgModule({
declarations: [
AppComponent,
CafeComponent,
ModalComponent,
NavComponent,
NewsFeedComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
JsonpModule,
ModalModule.forRoot(),
ModalModule,
NgbModule.forRoot(),
BootstrapModalModule,
AppRoutingModule
], …Run Code Online (Sandbox Code Playgroud)