angular5 ngx datatable error context

获取到api的数据,需要render 到datatable 上的时候出错,
取到的数据:是一个object
{"pool":[
{"pool_id":"2","libraries_library_id":"2"},
{"pool_id":"1","libraries_library_id":"1"}
]}

 

刷新页面:
 
PoolsDisplayComponent.html:5 ERROR TypeError: val.slice is not a function
at DatatableComponent.set [as rows] (index.js:2803)
at updateProp (core.js:12661)
at checkAndUpdateDirectiveInline (core.js:12368)
at checkAndUpdateNodeInline (core.js:13935)
at checkAndUpdateNode (core.js:13878)
at debugCheckAndUpdateNode (core.js:14771)
at debugCheckDirectivesFn (core.js:14712)
at Object.eval [as updateDirectives] (PoolsDisplayComponent.html:5)
at Object.debugUpdateDirectives [as updateDirectives] (core.js:14697)
at checkAndUpdateView (core.js:13844)
ERROR CONTEXT DebugContext_ {view: {…}, nodeIndex: 6, nodeDef: {…}, elDef: {…}, elView: {…}}
原因:
api返回的数据是object,而render datatable需要的是一个array
Typically the error you see happens when the data you try to render in the table is not Array type.
So in your case you have the object { feedData: [...array of objects...] }
And you need it to be: [...array of objects...]

转载于:https://www.cnblogs.com/imagin/p/9236381.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值