我爱编程

Can't bind to 'rows' since it is

2018-06-08  本文已影响0人  BGING

angular 使用 ngx-datatable 遇到的坑

开始用这个组件的时候就遇到坑爹的事情,访问 <ng-datatable> 模块就报错... 吐槽下谁说的把 ngx-datatable 导入 appModule 就可以全局使用,被这句话误导... 接下来说下使用的过程吧。

官网 https://swimlane.gitbook.io/ngx-datatable

出现问题

ERROR Error: Uncaught (in promise): Error: Template parse errors:
Can't bind to 'rows' since it isn't a known property of 'ngx-datatable'.
1. If 'ngx-datatable' is an Angular component and it has 'rows' input, then verify that it is part of this module.
2. If 'ngx-datatable' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("<div>
    <ngx-datatable [ERROR ->][rows]="rows" [columns]="columns">
    </ngx-datatable>
</div>"): ng:///ContentModel/UserListComponent.html@1:19
.
.
.

如果你的模块是通过路由加载的,你在 AppModule 里导入 NgxDatatableModule 也是没有用的。必须在 当前使用模块里导入 。我就是被误导,说在 AppModule 里导入就可以全局使用。

上一篇 下一篇

猜你喜欢

热点阅读