简体   繁体   English

在angular 6中重用ngx admin中的组件

[英]Reusing components in ngx admin in angular 6

I am using NGX Admin and I am stuck at reusing components. 我正在使用NGX Admin,并且无法重用组件。 I am trying to use smart table and pie charts inside the Dashboard but I am getting a template parse error. 我正在尝试在仪表板内使用智能表和饼图,但出现模板解析错误。 What I did was inside dashboard.module I added the module reference 我所做的是在dashboard.module中,我添加了模块参考

import { NgModule } from '@angular/core';    
import { NgxEchartsModule } from 'ngx-echarts';

import { ThemeModule } from '../../@theme/theme.module';
import { DashboardComponent } from './dashboard.component';
import { TablesModule } from '../tables/tables.module';


@NgModule({
  imports: [
    ThemeModule,
    NgxEchartsModule,
    TablesModule    
  ],
  declarations: [
    DashboardComponent,
  ],
})
export class DashboardModule { }

and then in the Dashboard.component I imported the table component 然后在Dashboard.component中,我导入了表格组件

  import {Component, OnDestroy} from '@angular/core';
import { NbThemeService } from '@nebular/theme';
import { takeWhile } from 'rxjs/operators/takeWhile' ;
import {SmartTableComponent} from '../tables/smart-table/smart-table.component'

@Component({
  selector: 'ngx-dashboard',
  styleUrls: ['./dashboard.component.scss'],
  templateUrl: './dashboard.component.html',
})
export class DashboardComponent { }

and then finally in the html file I added the tag 然后最后在html文件中,我添加了标签

<ng2-smart-table>
</ng2-smart-table>

but I am getting a template parse error. 但我收到模板解析错误。 The tag is not recognized. 无法识别标签。 Can someone please tell me what I am doing wrong here. 有人可以告诉我我在做什么错。

In your module.ts file add "Ng2SmartTableModule" in the imports and add tag in your component html. 在您的module.ts文件中,在导入中添加“ Ng2SmartTableModule”,并在组件html中添加标签。 In your Dashboard component you just import properties of ng2-smart-table like LocalDataSource - import { LocalDataSource } from 'ng2-smart-table';- to instantiate a source and load your data in your table. 在仪表板组件中,您只需导入ng2-smart-table的属性,例如LocalDataSource-从'ng2-smart-table'导入{LocalDataSource};-实例化源并将数据加载到表中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM