我正在玩Angular2,并试图让一个模块(BreadcrumbDemoModule)导入另一个模块(BreadcrumbModule).
目前,BreadcrumbModule只包含一个组件:ng2-breadcrumb.但是,当我尝试在BreadcrumbDemoModule中使用此组件时,我收到错误消息:
‘ng2-breadcrumb’ is not a known element.
我想我必须在某个地方错过一条线,并希望有人可以向我指出我做错了什么.
非常感谢你提前!
BreadcrumbModule的文件
breadcrumb.component.html:
THIS IS A BREADCRUMB TEST
breadcrumb.component.ts:
import { Component } from '@angular/core'; @Component({ selector: 'ng2-breadcrumb',template: require('./breadcrumb.component.html') }) export class BreadcrumbComponent {}
组件/面包屑/ index.ts:
import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { BreadcrumbComponent } from './breadcrumb.component'; @NgModule({ imports: [ BrowserModule //for later use ],declarations: [ BreadcrumbComponent ] }) export class BreadcrumbModule {}
BreadcrumbDemoModule的文件
面包屑demo.component.html:
<ng2-breadcrumb></ng2-breadcrumb>
面包屑demo.component.ts:
import { Component } from '@angular/core'; import { BreadcrumbModule } from './../index'; @Component({ selector: 'ng2-breadcrumb-demo',template: require('./breadcrumb-demo.component.html') }) export class BreadcrumbDemoComponent {}
组件/面包屑/演示/ index.ts:
import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { BreadcrumbModule } from './../index'; import { BreadcrumbDemoComponent } from './breadcrumb-demo.component'; @NgModule({ imports: [ BreadcrumbModule,BrowserModule,],declarations: [ BreadcrumbDemoComponent ] }) export class BreadcrumbDemoModule {}