角JS服务器端过滤器和分页 [英] Angular js server side filter and pagination

查看:102
本文介绍了角JS服务器端过滤器和分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个输入字段,我们可以使用一个输入字段与搜索作为例子的名称。当有人类型分为那场我希望能够过滤对象的结果。但我想要做的过滤服务器端没有客户端。我有很多记录的数据库,所以我不希望有返回他们都做过滤客户端,它真的会减慢速度。 ID也喜欢来实现分页具有角JS。任何指针?或一个方向,我应该头上?

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?

我使用MongoDB的作为分贝店

I use mongodb as a db store

推荐答案

下面是例如使用mongolab: http://jsfiddle.net / CLVpf / 2 /

Here is the example using mongolab: http://jsfiddle.net/CLVpf/2/

您可以只 $观看查询变量构造查询网址,
和呼叫查询() ngResource 实例。

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);
});

下面项目是ngResource实例。

Here Project is the ngResource instance.

这篇关于角JS服务器端过滤器和分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆