我有一个应用程序,主页面分为4个部分(页眉,边栏,内容和页脚).Sidebar里面有mainmenu组件。我的问题是,当我尝试将主菜单添加到侧边栏时,它会出现以下错误。
项目文件夹结构
app.component.ts
import { Component } from '@angular/core';
import { AppHeaderComponent } from './app-header';
import { AppSidebarComponent } from './app-sidebar';
import { AppContentComponent } from './app-content';
import { AppFooterComponent } from './app-footer';
@Component({
moduleId: module.id,
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.css'],
directives:[AppHeaderComponent,AppSidebarComponent,AppContentComponent,AppFooterComponent]
})
export class AppComponent {
title = 'app works!';
}
APP-sidebar.component.ts
import { Component, OnInit } from '@angular/core';
import { AppMainMenuComponent } from './app-mainmenu';
@Component({
moduleId: module.id,
selector: 'app-sidebar',
templateUrl: 'app-sidebar.component.html',
styleUrls: ['app-sidebar.component.css'],
directives:[AppMainMenuComponent]
})
export class AppSidebarComponent implements OnInit {
constructor() { }
ngOnInit() {}
}
APP-mainmenu.component.ts
import { Component, OnInit } from '@angular/core';
@Component({
moduleId: module.id,
selector: 'app-mainmenu',
templateUrl: 'app-mainmenu.component.html'
})
export class AppMainMenuComponent implements OnInit {
constructor() { }
ngOnInit() {}
}
重新加载时出错