This repository has been archived by the owner on Nov 19, 2021. It is now read-only.
forked from angular-ui/ui-select
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo-object-as-source.html
47 lines (41 loc) · 2.59 KB
/
demo-object-as-source.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
<button class="btn btn-default btn-xs" ng-click="ctrl.enable()">Enable ui-select</button>
<button class="btn btn-default btn-xs" ng-click="ctrl.disable()">Disable ui-select</button>
<button class="btn btn-default btn-xs" ng-click="ctrl.clear()">Clear ng-model</button>
<h1>Object as Item Source</h1>
<p>uiSelect supports providing choices using the <code>(key, value)</code> format, similar to that used by <code>ng-repeat</code></p>
<h3>Using value for binding</h3>
<p>Selected: <code>{{ctrl.person.selectedValue}}</code></p>
<ui-select ng-model="ctrl.person.selectedValue" theme="select2" ng-disabled="ctrl.disabled" style="min-width: 300px;" title="Choose a person">
<ui-select-match placeholder="Select a person in the list or search his name/age...">{{$select.selected.value.name}}</ui-select-match>
<ui-select-choices repeat="person.value as (key, person) in ctrl.peopleObj | filter: { value: { name: $select.search }}">
<div ng-bind-html="person.value.name | highlight: $select.search"></div>
<small>
email: {{person.value.email}}
age: {{person.value.age}}
</small>
</ui-select-choices>
</ui-select>
<h3>Using single property for binding</h3>
<p>Selected: <code>{{ctrl.person.selectedSingle}}</code></p>
<ui-select ng-model="ctrl.person.selectedSingle" theme="select2" ng-disabled="ctrl.disabled" style="min-width: 300px;" title="Choose a person">
<ui-select-match placeholder="Select a person in the list or search his name/age...">{{$select.selected.value.name}}</ui-select-match>
<ui-select-choices repeat="person.value.name as (key, person) in ctrl.peopleObj | filter: { value: { name: $select.search }}">
<div ng-bind-html="person.value.name | highlight: $select.search"></div>
<small>
email: {{person.value.email}}
age: {{person.value.age}}
</small>
</ui-select-choices>
</ui-select>
<h3>Using key for binding</h3>
<p>Selected: <code>{{ctrl.person.selectedSingleKey}}</code></p>
<ui-select ng-model="ctrl.person.selectedSingleKey" theme="select2" ng-disabled="ctrl.disabled" style="min-width: 300px;" title="Choose a person">
<ui-select-match placeholder="Select a person in the list or search his name/age...">{{$select.selected.value.name}}</ui-select-match>
<ui-select-choices repeat="person.key as (key, person) in ctrl.peopleObj | filter: { value: { name: $select.search }}">
<div ng-bind-html="person.value.name | highlight: $select.search"></div>
<small>
email: {{person.value.email}}
age: {{person.value.age}}
</small>
</ui-select-choices>
</ui-select>