我尝试ngx-datatable
在我的 angular 4 项目中使用 system.js 来加载模块,但它会引发如下错误:
无法绑定到“行”,因为它不是 ngx-datatable 的已知属性。
无法绑定到“列”,因为它不是 ngx-datatable 的已知属性。
ngx-datatable 不是已知元素:
我猜 system.js 没有正确加载模块,但我找不到有关如何执行此操作的工作演示。该文档也没有帮助。
system.config.js:
map: {
...
'@swimlane/ngx-datatable': 'npm:@swimlane/ngx-datatable/release/index.js',
...
}
app.module.ts:
import { NgxDatatableModule } from '@swimlane/ngx-datatable';
...
imports: [
...
NgxDatatableModule,
...
],
组件.html:
<ngx-datatable
[rows]="rows"
[columns]="columns">
</ngx-datatable>
组件.ts:
rows = [
{ name: 'Austin', gender: 'Male', company: 'Swimlane' },
{ name: 'Dany', gender: 'Male', company: 'KFC' },
{ name: 'Molly', gender: 'Female', company: 'Burger King' },
];
columns = [
{ prop: 'name' },
{ name: 'Gender' },
{ name: 'Company' }
];
包.json:
...
"@angular/animations": "^4.3.0",
"@angular/common": "^4.3.0",
"@angular/compiler": "^4.3.0",
"@angular/compiler-cli": "^4.3.0",
"@angular/core": "^4.3.0",
"@angular/forms": "^4.3.0",
"@angular/http": "^4.3.0",
"@angular/platform-browser": "^4.3.0",
"@angular/platform-browser-dynamic": "^4.3.0",
"@angular/platform-server": "^4.3.0",
"@angular/router": "^4.3.0",
"@angular/upgrade": "4.3.0",
"@swimlane/ngx-datatable": "^9.3.1",
...