admin管理员组文章数量:1425676
I have a couple of input fields, we can use an input field with the name of search as an example. when someone types into that field i want to be able to filter the results of an object. but i want to do the filter server side not client side. i have a database with a lot of records so i don't want to have to return them all and do the filtering client side, it really slows things down. id also like to implement pagination with angular js. any pointers? or a direction i should head?
I use mongodb as a db store
I have a couple of input fields, we can use an input field with the name of search as an example. when someone types into that field i want to be able to filter the results of an object. but i want to do the filter server side not client side. i have a database with a lot of records so i don't want to have to return them all and do the filtering client side, it really slows things down. id also like to implement pagination with angular js. any pointers? or a direction i should head?
I use mongodb as a db store
Share Improve this question asked Feb 4, 2013 at 21:30 AdamAdam 841 silver badge4 bronze badges 2- 1 This is a pretty broad/vague question. Certainly you can find examples around the web. If you have some code you're having an issue with or something more specific, that would make a better question. – Ben Lesh Commented Feb 4, 2013 at 21:41
- why do you want to do filtering on client side mongo db provide very fast filtering of its own – Ajay Singh Beniwal Commented Feb 5, 2013 at 6:50
1 Answer
Reset to default 5Here is the example using mongolab: http://jsfiddle/CLVpf/2/
You can just $watch
the query variable to construct query URL,
and call query()
against the ngResource
instance.
$scope.$watch('search', function (key) {
var q = null;
if (key) {
q = {
q: '{name:{$regex:"' + key + '"}}'
};
}
$scope.projects = Project.query(q);
});
Here Project
is the ngResource instance.
本文标签: javascriptAngular js server side filter and paginationStack Overflow
版权声明:本文标题:javascript - Angular js server side filter and pagination - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745457567a2659175.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论