angular - 在 Angular 6 中重用 ngx admin 中的组件
问题描述
我正在使用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 - import { LocalDataSource } from 'ng2-smart-table';- 以实例化源并将数据加载到表中。
推荐阅读
- flutter - 谷歌地图初始相机位置未设置
- mysql - mysql 多行中连续日期的开始和结束日期
- typescript - 如何声明 T[K] 为 X 类型的函数参数类型的索引器类型,因此 t[k]=x 将是一个有效的表达式
- php - 警告:file_get_contents():SSL 操作失败,代码为 1。OpenSSL 错误消息:错误:1416F086:
- r - 根据当前值有条件地重命名单元格
- facebook - 登录错误 Facebook:“URL 被阻止:此重定向失败,因为重定向 URI 未在应用程序的客户端 OAuth 设置中列入白名单。”
- sql - 将来自两个表的 If/Case 连接的值插入到第三个表中
- bash - 如何创建一个 bash 脚本来打开我的一些应用程序?
- c# - 使用 C# WinForms 登录到 SharePoint 2019 OnPremise
- maven - JAVA_HOME 环境变量未正确定义 运行此程序需要此环境变量