In Angular, is there a way to modify the filter such that it only returns exact matches?
Example:
var words = [ { title: \"ball\" }, {
You can use Regex to achieve a simple implementation:
In the controller: $scope.myFilter = function (word) { if ($scope.query === '') return true; var reg = RegExp("^" + $scope.query + "$"); return reg.test(word.title); }; 0 讨论(0) 查看其它6个回答 发布评论: 提交评论 加载中... 验证码 看不清? 提交回复 热议问题
In the controller:
$scope.myFilter = function (word) { if ($scope.query === '') return true; var reg = RegExp("^" + $scope.query + "$"); return reg.test(word.title); };