Angular组件并使用它们

时间:2018-03-28 12:03:19

标签: angular angular-material

我是angular2 +的新手,想了解如何使用已构建的Angular + Material2构建的框架 https://github.com/codetok/cdk-admin

我已经在那里开了一个问题,但是我很高兴能够使用它,所以我就这么问了。

我想将一个组件用作组件,它实际上是用路由器呈现的。有人可以给我一个参考或一个例子,说明我在这种情况下如何使用该组件。

https://github.com/codetok/cdk-admin/issues/4

更新:这是我想要运行应用程序的模块。

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';
import { DashboardCrmComponent } from './dashboard-crm.component';
import { FlexLayoutModule } from '@angular/flex-layout';
import { MatCardModule } from '@angular/material/card';
import { DashboardWidgetModule } from '../dashboard-widget/dashboard-widget.module';
import { TablesModule } from '../tables/tables.module';
import { FilterTableComponent } from '../tables/filter-table/filter-table.component';

export const appRoutes: Routes = [
  {path: '', component: DashboardCrmComponent},
];

@NgModule({
  imports: [
    CommonModule,
    RouterModule.forChild(appRoutes),
    FlexLayoutModule,
    MatCardModule,
    DashboardWidgetModule,
    TablesModule //here is the module
  ],
  declarations: [DashboardCrmComponent, FilterTableComponent],
  exports: []
})
export class DashboardCrmModule {
}

我收到的错误:

core.js:1440 ERROR Error: Uncaught (in promise): Error: Template parse errors:
    'cdk-filter-table' is not a known element:
    1. If 'cdk-filter-table' is an Angular component, then verify that it is part of this module.
    2. If 'cdk-filter-table' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("<div fxLayout="row" fxLayoutWrap>
      [ERROR ->]<cdk-filter-table></cdk-filter-table>
    </div>
    <!--<div fxLayout="row" fxLayoutWrap>
    "): ng:///DashboardCrmModule/DashboardCrmComponent.html@1:2
    Error: Template parse errors:
    'cdk-filter-table' is not a known element:
    1. If 'cdk-filter-table' is an Angular component, then verify that it is part of this module.
    2. If 'cdk-filter-table' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("<div fxLayout="row" fxLayoutWrap>
      [ERROR ->]<cdk-filter-table></cdk-filter-table>
    </div>

0 个答案:

没有答案