[英]Reusing components in ngx admin in angular 6
我正在使用NGX Admin,並且無法重用組件。 我正在嘗試在儀表板內使用智能表和餅圖,但出現模板解析錯誤。 我所做的是在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 { }
然后在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 { }
然后最后在html文件中,我添加了標簽
<ng2-smart-table>
</ng2-smart-table>
但我收到模板解析錯誤。 無法識別標簽。 有人可以告訴我我在做什么錯。
在您的module.ts文件中,在導入中添加“ Ng2SmartTableModule”,並在組件html中添加標簽。 在儀表板組件中,您只需導入ng2-smart-table的屬性,例如LocalDataSource-從'ng2-smart-table'導入{LocalDataSource};-實例化源並將數據加載到表中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.