如何使用smart-table和angularjs实现自定义搜索

use*_*492 10 angularjs smart-table

有没有办法用智能表搜索日期字段?我需要在给定日期之后过滤日期.

lau*_*ent 16

您可以使用该st-set-filter属性设置自定义(全局过滤器)(尚未记录)

<table st-set-filter="myFilter" st-table="rowCollection">
  ...
</table>
Run Code Online (Sandbox Code Playgroud)

然后实现自定义过滤器

myApp.filter('myFilter',[function(){
    return function(array, expression){
       //an example
       return array.filter(function(val, index){
           return new Date(val.theDateProperty) > new Date(expression.theDateProperty) ;
       });
    }
});
Run Code Online (Sandbox Code Playgroud)

例如,您已在表中设置输入

<input type="date" st-search="'theDateProperty'" />
Run Code Online (Sandbox Code Playgroud)

请注意,过滤器对表是全局的,因此将调用它来代替角度过滤器(使用的默认值)用于非常搜索输入.因此,如果您需要针对不同列的其他过滤器行为,则必须将它们添加到自定义过滤器中,或者其他技术是使用比较器功能.您可以在我对拉动请求(2014年11月18日)的评论中找到更多详细信息

编辑:

它已被记录在案.