Skip to content

Instantly share code, notes, and snippets.

@wildermuthn
Last active August 29, 2015 14:16
Show Gist options
  • Save wildermuthn/d846f0b98e112474c0bf to your computer and use it in GitHub Desktop.
Save wildermuthn/d846f0b98e112474c0bf to your computer and use it in GitHub Desktop.
no need for switches
<input class="input-search" type="text" ng-model="filter.search" name="" id="" value="" />
var fn = {
'search': function(search) {
var matchDetails = function(row, val) {
var titleIndex = $scope.table.columns.indexOf('details');
var result = row[titleIndex].search(val) == -1 ? false : true;
return result;
}
$scope.table.rows = R.filter((row) => matchDetails(row, search), table.rows);
},
}
$scope.$watchCollection('filter', function(filter) {
R.mapObjIndexed((val, key) => fn[key](val), filter);
});
@wildermuthn
Copy link
Author

Person types into input box.
Line 2 is automatically called with the value in the input box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment