Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit 9d1bd79

Browse files
committed
Add demo
1 parent 35c2584 commit 9d1bd79

File tree

2 files changed

+178
-1
lines changed

2 files changed

+178
-1
lines changed

examples/demo-multi-select.html

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
<!DOCTYPE html>
2+
<html lang="en" ng-app="demo">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>AngularJS ui-select</title>
6+
7+
<!--
8+
IE8 support, see AngularJS Internet Explorer Compatibility http://docs.angularjs.org/guide/ie
9+
For Firefox 3.6, you will also need to include jQuery and ECMAScript 5 shim
10+
-->
11+
<!--[if lt IE 9]>
12+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.js"></script>
13+
<script src="http://cdnjs.cloudflare.com/ajax/libs/es5-shim/2.2.0/es5-shim.js"></script>
14+
<script>
15+
document.createElement('ui-select');
16+
document.createElement('ui-select-match');
17+
document.createElement('ui-select-choices');
18+
</script>
19+
<![endif]-->
20+
21+
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.js"></script>
22+
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular-sanitize.js"></script>
23+
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.css">
24+
25+
<!-- ui-select files -->
26+
<script src="../dist/select.js"></script>
27+
<link rel="stylesheet" href="../dist/select.css">
28+
29+
<script src="demo.js"></script>
30+
31+
<!-- Select2 theme -->
32+
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/select2/3.4.5/select2.css">
33+
34+
<!--
35+
Selectize theme
36+
Less versions are available at https://github.com/brianreavis/selectize.js/tree/master/dist/less
37+
-->
38+
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.8.5/css/selectize.default.css">
39+
<!-- <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.8.5/css/selectize.bootstrap2.css"> -->
40+
<!-- <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.8.5/css/selectize.bootstrap3.css"> -->
41+
42+
<style>
43+
body {
44+
padding: 15px;
45+
}
46+
47+
.select2 > .select2-choice.ui-select-match {
48+
/* Because of the inclusion of Bootstrap */
49+
height: 29px;
50+
}
51+
52+
.selectize-control > .selectize-dropdown {
53+
top: 36px;
54+
}
55+
</style>
56+
</head>
57+
58+
<body ng-controller="DemoCtrl">
59+
<script src="demo.js"></script>
60+
61+
<button class="btn btn-default btn-xs" ng-click="enable()">Enable ui-select</button>
62+
<button class="btn btn-default btn-xs" ng-click="disable()">Disable ui-select</button>
63+
<button class="btn btn-default btn-xs" ng-click="clear()">Clear ng-model</button>
64+
65+
<!-- <h1>Bootstrap theme</h1>
66+
<ui-select ng-model="address.selected"
67+
theme="bootstrap"
68+
ng-disabled="disabled"
69+
reset-search-input="false"
70+
style="width: 300px;">
71+
<ui-select-match placeholder="Enter an address...">{{$select.selected.formatted_address}}</ui-select-match>
72+
<ui-select-choices repeat="address in addresses track by $index"
73+
refresh="refreshAddresses($select.search)"
74+
refresh-delay="0">
75+
<div ng-bind-html="address.formatted_address | highlight: $select.search"></div>
76+
</ui-select-choices>
77+
</ui-select>
78+
<p>Selected: {{address.selected.formatted_address}}</p>
79+
80+
<h3>Multi select</h3>
81+
<ui-select multiple ng-model="friends" theme="bootstrap" ng-disabled="disabled" style="width: 300px;">
82+
<ui-select-match placeholder="Search and select friends...">{{$item.name}}</ui-select-match>
83+
<ui-select-choices repeat="person in people | propsFilter: {name: $select.search, age: $select.search}">
84+
<div ng-bind-html="person.name | highlight: $select.search"></div>
85+
<small>
86+
age: <span ng-bind-html="''+person.age | highlight: $select.search"></span>
87+
</small>
88+
</ui-select-choices>
89+
</ui-select>
90+
<p>Selected: {{friends|json}}</p>
91+
-->
92+
<!-- <ui-select ng-model="person.selected" theme="select2" ng-disabled="disabled" style="min-width: 300px;">
93+
<ui-select-match placeholder="Select a person in the list or search his name/age...">{{$select.selected.name}}</ui-select-match>
94+
<ui-select-choices repeat="person in people | propsFilter: {name: $select.search, age: $select.search}">
95+
<div ng-bind-html="person.name | highlight: $select.search"></div>
96+
<small>
97+
email: {{person.email}}
98+
age: <span ng-bind-html="''+person.age | highlight: $select.search"></span>
99+
</small>
100+
</ui-select-choices>
101+
</ui-select>
102+
<p>Selected: {{person.selected}}</p> -->
103+
<!-- <h1>Selectize theme</h1>
104+
<ui-select ng-model="country.selected" theme="selectize" ng-disabled="disabled" style="width: 300px;">
105+
<ui-select-match placeholder="Select or search a country in the list...">{{$select.selected.name}}</ui-select-match>
106+
<ui-select-choices repeat="country in countries | filter: $select.search">
107+
<span ng-bind-html="country.name | highlight: $select.search"></span>
108+
<small ng-bind-html="country.code | highlight: $select.search"></small>
109+
</ui-select-choices>
110+
</ui-select>
111+
<p>Selected: {{country.selected}}</p> -->
112+
113+
<h1>Multi Selection Demos</h1>
114+
115+
<h3>Array of strings</h3>
116+
<ui-select multiple ng-model="multipleDemo.colors" theme="bootstrap" ng-disabled="disabled" style="width: 300px;">
117+
<ui-select-match placeholder="Select colors...">{{$item}}</ui-select-match>
118+
<ui-select-choices repeat="color in availableColors | filter:$select.search">
119+
{{color}}
120+
</ui-select-choices>
121+
</ui-select>
122+
<p>Selected: {{multipleDemo.colors}}</p>
123+
<hr>
124+
<h3>Array of objects</h3>
125+
<ui-select multiple ng-model="multipleDemo.selectedPeople" theme="bootstrap" ng-disabled="disabled" style="width: 800px;">
126+
<ui-select-match placeholder="Select person...">{{$item.name}} &lt;{{$item.email}}&gt;</ui-select-match>
127+
<ui-select-choices repeat="person in people | propsFilter: {name: $select.search, age: $select.search}">
128+
<div ng-bind-html="person.name | highlight: $select.search"></div>
129+
<small>
130+
email: {{person.email}}
131+
age: <span ng-bind-html="''+person.age | highlight: $select.search"></span>
132+
</small>
133+
</ui-select-choices>
134+
</ui-select>
135+
<p>Selected: {{multipleDemo.selectedPeople}}</p>
136+
137+
<hr>
138+
<h3>Array of objects with single property binding</h3>
139+
<ui-select multiple ng-model="multipleDemo.selectedPeopleSimple" theme="bootstrap" ng-disabled="disabled" style="width: 800px;">
140+
<ui-select-match placeholder="Select person...">{{$item.name}} &lt;{{$item.email}}&gt;</ui-select-match>
141+
<ui-select-choices repeat="person.email as person in people | propsFilter: {name: $select.search, age: $select.search}">
142+
<div ng-bind-html="person.name | highlight: $select.search"></div>
143+
<small>
144+
email: {{person.email}}
145+
age: <span ng-bind-html="''+person.age | highlight: $select.search"></span>
146+
</small>
147+
</ui-select-choices>
148+
</ui-select>
149+
<p>Selected: {{multipleDemo.selectedPeopleSimple}}</p>
150+
151+
<hr>
152+
<h3>Array of objects (with groupBy)</h3>
153+
<ui-select multiple ng-model="multipleDemo.selectedPeopleWithGroupBy" theme="bootstrap" ng-disabled="disabled" style="width: 800px;">
154+
<ui-select-match placeholder="Select person...">{{$item.name}} &lt;{{$item.email}}&gt;</ui-select-match>
155+
<ui-select-choices group-by="someGroupFn" repeat="person in people | propsFilter: {name: $select.search, age: $select.search}">
156+
<div ng-bind-html="person.name | highlight: $select.search"></div>
157+
<small>
158+
email: {{person.email}}
159+
age: <span ng-bind-html="''+person.age | highlight: $select.search"></span>
160+
</small>
161+
</ui-select-choices>
162+
</ui-select>
163+
<p>Selected: {{multipleDemo.selectedPeopleWithGroupBy}}</p>
164+
165+
<div style="height:500px"></div>
166+
167+
</body>
168+
</html>

examples/demo.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,18 @@ app.controller('DemoCtrl', function($scope, $http, $timeout) {
110110
{ name: 'Nicole', email: '[email protected]', age: 43, country: 'Colombia' },
111111
{ name: 'Natasha', email: '[email protected]', age: 54, country: 'Ecuador' },
112112
{ name: 'Michael', email: '[email protected]', age: 15, country: 'Colombia' },
113-
{ name: 'Nicolás', email: 'nicole@email.com', age: 43, country: 'Colombia' }
113+
{ name: 'Nicolás', email: 'nicolas@email.com', age: 43, country: 'Colombia' }
114114
];
115115

116+
$scope.availableColors = ['Red','Green','Blue','Yellow','Magenta','Maroon','Umbra','Turquoise'];
117+
118+
$scope.multipleDemo = {};
119+
$scope.multipleDemo.colors = ['Blue','Red'];
120+
$scope.multipleDemo.selectedPeople = [$scope.people[5], $scope.people[4]];
121+
$scope.multipleDemo.selectedPeopleWithGroupBy = [$scope.people[8], $scope.people[6]];
122+
$scope.multipleDemo.selectedPeopleSimple = ['[email protected]','[email protected]'];
123+
124+
116125
$scope.address = {};
117126
$scope.refreshAddresses = function(address) {
118127
var params = {address: address, sensor: false};

0 commit comments

Comments
 (0)