美文网首页我爱编程
Can't bind to 'rows' since it is

Can't bind to 'rows' since it is

作者: BGING | 来源:发表于2018-06-08 12:24 被阅读0次

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 里导入就可以全局使用。

  • 配套的版本过低(typescript版本、)

    这个没有校验过,不过通过他们讨论的结果看,也是有关系的。

    ngx-datatable 的 issues

相关文章

网友评论

    本文标题:Can't bind to 'rows' since it is

    本文链接:https://www.haomeiwen.com/subject/hezosftx.html