Can't bind to 'rows' since it isn't a known property of 'ngx-datatable'.

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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 大多数 Nginx 新手都会频繁遇到这样一个困惑,那就是当同一个location配置块使用了多个 Nginx 模块...
    SkTj阅读 7,842评论 0 12
  • 框架代码分析 核心模块 启动过程(main) 1、全局ngx_cycle_t对象 1、ngx_init_cycle...
    AKEEM阅读 1,161评论 1 0
  • 正月开岁 二月绀香 三月桃良 四月绣蔓 转眼之间 五月鸣蜩 时间好快 暗自神伤
    日事日毕阅读 402评论 0 20