angularjs – 带有通配符的Underscorejs _.where

前端之家收集整理的这篇文章主要介绍了angularjs – 带有通配符的Underscorejs _.where前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在AngularJS控制器中有以下内容

$scope.initiatives = _.where($scope.initiatives,{i_status_id:'Open'});

如果属性值完全为“打开”,则可以根据字段过滤列表.

如何在过滤器值中使用通配符,以便在搜索包含“Open”的所有内容时,它会选择“Open – Pending”?

解决方法

您可以使用 _.filter.就像是:

$scope.initiatives = _.filter($scope.initiatives,function(initiative){
    return initiative.i_status_id.indexOf('Open')>=0;
});

猜你在找的Angularjs相关文章