如果我使用其他api,则无法进行角表排序 [英] Angular Table sorting does not work if i use a different api
本文介绍了如果我使用其他api,则无法进行角表排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我以
http://ng-table.com/#/loading/demo -external-array
用代码笔打开它,而不是使用API来代替"/data".
opened it in code pen and instead of "/data" i am using an api
https://jsonplaceholder.typicode.com/posts
并添加了isArray:true
and added isArray : true
var Api = $resource("https://jsonplaceholder.typicode.com/posts", {}, {
'get': { method: 'GET', isArray: true}
});
在html中,为了简单起见,我取出了所有列并保留了"id"列
in html i took out all the columns and kept "id" column for simplicity
它加载id列,但是搜索排序不起作用.
it loads id column but searching sorting does not work.
我做错了什么?
笔在这里
http://codepen.io/raasmasood/pen/zoeMgx
推荐答案
http://codepen.io/anon/pen/rWRNjQ
您可以检查该密码笔,现在可以使用了. ;)
you could check this codepen, now it works. ;)
getData: function(params) {
// ajax request to api
return Api.get(params.url()).$promise.then(function(data) {
params.total(100); // recal. page nav controls
return ($filter('orderBy')(data, params.orderBy()));
//return data;
});
}
以前,我们错过了过滤器部分.
Previously there we missed the filter part.
return $filter('filter')($filter('orderBy')(data, params.orderBy()),params.filter());
也启用过滤器:)
这篇关于如果我使用其他api,则无法进行角表排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文