-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypeahead.html
64 lines (54 loc) · 3.03 KB
/
typeahead.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!doctype html>
<html ng-app="typeaheadApp">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular.js"></script>
<script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.13.0.js"></script>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<script type="text/ng-template" id="userTypeaheadRow.html">
<a ng-disabled="true" class="cd-typeaheadrow">
<div class="name">{{match.model.name}} <span class="email">{{match.model.company}}</span></div>
<div class="company">{{match.model.userId}} <<span>{{match.model.email}}</span>></div>
</a>
</script>
<div>
<div class="container-fluid" ng-controller="TypeaheadCtrl">
<h2>Angular.js Typeahead</h2>
<div class="form-group">
<input type="text" class="form-control cd-docperm-typeahead" placeholder="Search Users"
typeahead="user as user.userId for user in users | filter:$viewValue | limitTo:8"
ng-model="typeaheadSelected"
ng-change="clearBadSearchCriteria()"
typeahead-min-length="3"
typeahead-template-url="userTypeaheadRow.html"
typeahead-wait-ms="100"
/>
</div>
</div>
</div>
<script type="text/javascript">
var app = angular.module('typeaheadApp', ['ui.bootstrap']);
app.controller('TypeaheadCtrl', function($scope, Users) {
$scope.typeaheadSelected = '';
$scope.users = Users;
});
app.factory('Users', function() {
var users = [
{"userId": "tcopper", "name": "Tiancum Copper", "company": "Acme", "email": "[email protected]", "userType": "EXTERNAL", "admin": true},
{"userId": "mbystedt", "name": "Heather McLane", "company": "Cisco", "email": "[email protected]", "userType": "INTERNAL", "admin": true},
{"userId": "dsunder", "name": "David Sundersingh", "company": "Cisco", "email": "[email protected]", "userType": "INTERNAL", "admin": true},
{"userId": "jacob", "name": "Heather Bob", "company": "Cisco", "email": "[email protected]", "userType": "INTERNAL", "admin": true},
{"userId": "josh", "name": "Josh Hill", "company": "Acme", "email": "[email protected]", "userType": "EXTERNAL", "admin": true},
{"userId": "deadted", "name": "Ted Bob", "company": "Acme", "email": "[email protected]", "userType": "EXTERNAL", "admin": true},
{"userId": "mred", "name": "Better Red", "company": "Acme", "email": "[email protected]", "userType": "EXTERNAL", "admin": true},
{"userId": "maven", "name": "Moroni Maven", "company": "Acme", "email": "[email protected]", "userType": "EXTERNAL", "admin": true},
{"userId": "tiancum", "name": "Tiancum Train", "company": "Acme", "email": "[email protected]", "userType": "EXTERNAL", "admin": true},
{"userId": "bianica", "name": "Heather Jellyfish", "company": "Acme", "email": "[email protected]", "userType": "EXTERNAL", "admin": true},
{"userId": "trill", "name": "Trillium Flower", "company": "Acme", "email": "[email protected]", "userType": "EXTERNAL", "admin": true}
];
return users;
});
</script>
</body>
</html>