Last active
August 29, 2015 14:16
-
-
Save wildermuthn/d846f0b98e112474c0bf to your computer and use it in GitHub Desktop.
no need for switches
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input class="input-search" type="text" ng-model="filter.search" name="" id="" value="" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Person types into input box.
Line 2 is automatically called with the value in the input box.