when filtering matches, ignore img tags

fix-space-nbsp
Dmitri Akatov 11 years ago
parent 7aa7cbe639
commit 07bc5cbd4a

@ -26,7 +26,7 @@ angular.module('typeahead', ['ui.bootstrap', 'radians'])
<body>
<div class='container-fluid' ng-controller="TypeaheadCtrl">
<pre>Model: {{ selected | json }}</pre>
<div ng-model="selected" typeahead="state for state in states | filter:$viewValue" contenteditable>
<div ng-model="selected" typeahead="state for state in states | ignoreImgFilter:$viewValue" contenteditable>
</div>
<!-- <input type="text" ng-model="selected" typeahead="state for state in states | filter:$viewValue"> -->
</div>

@ -24,3 +24,9 @@ angular.module('radians.contenteditable', [])
.filter('typeaheadHighlight', ->
(matchItem, query) -> matchItem
)
.filter('ignoreImgFilter', ->
noImg = (s) -> s.replace(/<img[^>]*>/, '')
(items, query) ->
item for item in items \
when noImg(item).match(new RegExp(noImg(query), 'gi'))
)