如何包括在angular2
一个模板指令我有2个组件, 1)Table.component 2)Dashboard.component如何包括在angular2
我想用表格模板在仪表板组件和我宣布选择素TOR在表组件中作为
selector: '[tables-basic]',
table.template中是否包含任何内容?
我进口仪表板模块表成分,我声明了组件的名称,把选择的仪表板组件作为
<tables-basic></tables-basic>
但我得到了错误的
1. If 'tables-basic' is an Angular component, then verify that it is part of this module.
2. If 'tables-basic' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schema' of this component to suppress this message. (" <div id="tabs2c" class="tab-content bg-info-light">
<div id = "tab2">
[ERROR ->]<tables-basic></tables-basic>
</div>
<!--
难道我错过任何事情。任何人都可以请建议帮助。 我的UIElement module.ts,
import { CommonModule } from '@angular/common';
import { FormsModule,ReactiveFormsModule } from '@angular/forms';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { RouterModule } from '@angular/router';
import { AlertModule, TooltipModule } from 'ng2-bootstrap/ng2-bootstrap';
import { ButtonsModule, DropdownModule, PaginationModule } from 'ng2-bootstrap/ng2-bootstrap';
import { DataTableDirectives } from 'angular2-datatable/datatable';
import { Ng2TableModule } from 'ng2-table';
import { HttpModule } from '@angular/http';
import { WidgetModule } from '../layout/widget/widget.module';
import { UtilsModule } from '../layout/utils/utils.module';
import { JqSparklineModule } from '../components/sparkline/sparkline.module';
import 'parsleyjs';
//import { TablesBasic } from './basic/tables-basic.component';
import { TablesDynamic } from './dynamic/tables-dynamic.component';
import { SearchPipe } from './dynamic/pipes/search-pipe';
import {Ng2PaginationModule} from 'ng2-pagination';
export const routes = [
{path: '', redirectTo: 'basic', pathMatch: 'full'},
// {path: 'basic', component: TablesBasic},
{path: 'dynamic', component: TablesDynamic},
];
@NgModule({
declarations: [
// Components/Directives/ Pipes
DataTableDirectives,
// TablesBasic,
TablesDynamic,
SearchPipe
],
imports: [
CommonModule,
Ng2PaginationModule,
HttpModule,
ReactiveFormsModule,
JqSparklineModule,
FormsModule,
AlertModule,
TooltipModule,
ButtonsModule,
DropdownModule,
PaginationModule,
WidgetModule,
UtilsModule,
Ng2TableModule,
RouterModule.forChild(routes)
],
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
})
export default class UiElementsModule {
static routes = routes;
}
要么改变选择器
selector: 'tables-basic',
或元件
<div tables-basic></div tables-basic>
(其中div
可以是任何元件)
selector: '[tables-basic]',
是一个属性选择器,需要一个垫子ching属性不是元素名称。
看来我犯了一个错误,我改变了选择器,然后我面临这个错误 – Arnold
错误:类型TablesBasic是2个模块的声明的一部分:AppModule和UiElementsModule!请考虑将TablesBasic移动到导入AppModule和UiElementsModule的较高模块。 – Arnold
为该指令创建一个新的'NgModule',将该指令添加到新'NgModule'的'declarations:[]'和exports:[]',然后将这个模块添加到'imports:[MySharedModule]'中模块你想使用它的地方。您不能将组件,指令或管道添加到多个模块的'声明:[]'。 –
在这里分享你的模块文件代码。 – ranakrunal9
['tables-basic'的可能重复是一个Angular组件,然后验证它是这个模块的一部分](http://*.com/questions/40458135/tables-basic-is-an-angular-component-然后验证它是这个模块的一部分) – Sefa