我使用的是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>但是我得到了一个模板解析错误。无法识别该标记。有人能告诉我我哪里做错了吗?
发布于 2019-01-16 17:03:04
在您的module.ts文件中,在imports中添加"Ng2SmartTableModule“,并在组件html中添加标记。在您的仪表板组件中,您只需导入ng2-smart-table的属性,如LocalDataSource - import { LocalDataSource } from 'ng2-smart- table ';-以实例化一个源并将数据加载到您的表中。
https://stackoverflow.com/questions/51586965
复制相似问题