Underscorejs _.where with template

The AngularJS controller has the following:

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

It works great to filter a list based on a field if the property value is "Open."

How do you use a wildcard in the filter value so that it collects "Open - Pending" if I look for all those that contain "Open"?

+4
source share
1 answer

You can use _.filter . Sort of:

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

Source: https://habr.com/ru/post/1483458/


All Articles