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...]
相關文章
相關標籤/搜索