|
| 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.2.18/angular.js"></script> |
| 22 | + <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.18/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 | + |
| 60 | + <button class="btn btn-default btn-xs" ng-click="enable()">Enable ui-select</button> |
| 61 | + <button class="btn btn-default btn-xs" ng-click="disable()">Disable ui-select</button> |
| 62 | + <button class="btn btn-default btn-xs" ng-click="clear()">Clear ng-model</button> |
| 63 | + |
| 64 | + <h1>(key, value) format</h1> |
| 65 | + |
| 66 | + <h2>Using value for binding</h2> |
| 67 | + |
| 68 | + <p>Selected: {{person.selectedValue}}</p> |
| 69 | + <ui-select ng-model="person.selectedValue" theme="select2" ng-disabled="disabled" style="min-width: 300px;" title="Choose a person"> |
| 70 | + <ui-select-match placeholder="Select a person in the list or search his name/age...">{{$select.selected.value.name}}</ui-select-match> |
| 71 | + <ui-select-choices repeat="person.value as (key, person) in peopleObj | filter: {'value':$select.search}"> |
| 72 | + <div ng-bind-html="person.value.name | highlight: $select.search"></div> |
| 73 | + <small> |
| 74 | + email: {{person.value.email}} |
| 75 | + age: <span ng-bind-html="''+person.value.age | highlight: $select.search"></span> |
| 76 | + </small> |
| 77 | + </ui-select-choices> |
| 78 | + </ui-select> |
| 79 | + |
| 80 | + <h2>Using single property for binding</h2> |
| 81 | + <p>Selected: {{person.selectedSingle}}</p> |
| 82 | + <ui-select ng-model="person.selectedSingle" theme="select2" ng-disabled="disabled" style="min-width: 300px;" title="Choose a person"> |
| 83 | + <ui-select-match placeholder="Select a person in the list or search his name/age...">{{$select.selected.value.name}}</ui-select-match> |
| 84 | + <ui-select-choices repeat="person.value.name as (key, person) in peopleObj | filter: {'value':$select.search}"> |
| 85 | + <div ng-bind-html="person.value.name | highlight: $select.search"></div> |
| 86 | + <small> |
| 87 | + email: {{person.value.email}} |
| 88 | + age: <span ng-bind-html="''+person.value.age | highlight: $select.search"></span> |
| 89 | + </small> |
| 90 | + </ui-select-choices> |
| 91 | + </ui-select> |
| 92 | + |
| 93 | + <h2>Using key for binding</h2> |
| 94 | + <p>Selected: {{person.selectedSingleKey}}</p> |
| 95 | + <ui-select ng-model="person.selectedSingleKey" theme="select2" ng-disabled="disabled" style="min-width: 300px;" title="Choose a person"> |
| 96 | + <ui-select-match placeholder="Select a person in the list or search his name/age...">{{$select.selected.value.name}}</ui-select-match> |
| 97 | + <ui-select-choices repeat="person.key as (key, person) in peopleObj | filter: {'value':$select.search}"> |
| 98 | + <div ng-bind-html="person.value.name | highlight: $select.search"></div> |
| 99 | + <small> |
| 100 | + email: {{person.value.email}} |
| 101 | + age: <span ng-bind-html="''+person.value.age | highlight: $select.search"></span> |
| 102 | + </small> |
| 103 | + </ui-select-choices> |
| 104 | + </ui-select> |
| 105 | + |
| 106 | +</body> |
| 107 | +</html> |
0 commit comments