You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
angular-contenteditable/test/fixtures/typeahead2.html

51 lines
1.7 KiB
HTML

<!DOCTYPE html>
<html lang="en" ng-app="typeahead2">
<head>
<meta charset="utf-8">
<link href="../../bower_components/bootstrap-css/css/bootstrap.css" rel="stylesheet">
<script src="../../bower_components/jquery/jquery.js"></script>
<script src="../../bower_components/angular-unstable/angular.js"></script>
<script src="../../bower_components/angular-bootstrap/ui-bootstrap.js"></script>
<script src="../../bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<script src="../../angular-contenteditable.js"></script>
<script>
angular.module('typeahead2', ['ui.bootstrap', 'contenteditable'])
.controller('Typeahead2Ctrl', function ($scope) {
$scope.selected = undefined
$scope.states =
[ 'Russia <img src="img/ru.gif">'
, 'USA <img src="img/us.gif">'
, 'UK <img src="img/gb.gif">'
]
})
.filter('ignoreImg', function(){
var escapeRegexp = function(str) {
return str.replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1")
}
var noImg = function (str) {
return str.replace(/<img[^>]*>/g, '')
}
return function(items, query) {
var ret = []
items.forEach(function(item){
if (noImg(item).match(new RegExp(escapeRegexp(noImg(query)), 'gi')))
ret.push(item)
})
return ret
}
})
// override typeahead's Highlight filter - don't highlight anything
.filter('typeaheadHighlight', function() {
return function(matchItem, query){return matchItem}
})
</script>
</head>
<body>
<div class='container-fluid' ng-controller="Typeahead2Ctrl">
<pre>Model: {{ selected | json }}</pre>
<div ng-model="selected" typeahead="state for state in states | ignoreImg:$viewValue" contenteditable>
</div>
</div>
</body>
</html>