-
Notifications
You must be signed in to change notification settings - Fork 0
/
async.html
117 lines (98 loc) · 3.93 KB
/
async.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!DOCTYPE html>
<html ng-app="app">
<head>
<meta charset="utf-8">
<title>ng-ui-multi-select</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="dist/ng-ui-multi-select.css">
</head>
<body ng-controller="ctrl"> <br><br>
<style media="screen">
body{
background: #f5f5f5;
}
</style>
<main>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Funcionarios: </label>
<ui-multi-select placeholder="Buscar..."
ng-model="funcionarios"
close-on-select-item="false"
on-selected="onSelect(value)"
on-remove="onRemove(value)"
search-options="getOptions(value)">
<ui-multi-select-item ng-repeat="item in funcionarios" ng-value="item">
{{item.name}}
</ui-multi-select-item>
<ui-multi-select-option ng-repeat="option in items" ng-value="option">
{{option.name}}
</ui-multi-select-option>
</ui-multi-select>
</div>
</div>
<div class="col-md-8">
<label>Model: </label>
<pre>{{funcionarios|json}}</pre>
</div>
</div>
<div class="row" ng-non-bindable>
<div class="col-md-6">
<h3>HTML</h3>
<pre><code style="font-size: 10px;" class="prettyprint"><div class="form-group">
<label>Funcionarios: </label>
<ui-multi-select placeholder="Buscar..."
close-on-select-item="false"
ng-model="funcionarios"
search-options="getOptions(value)">
<ui-multi-select-item ng-repeat="item in funcionarios"
ng-value="item">
{{item.username}}
</ui-multi-select-item>
<ui-multi-select-option ng-repeat="option in items"
ng-value="option">
{{option.username}}
</ui-multi-select-option>
</ui-multi-select>
</div></code></pre>
</div>
<div class="col-md-6">
<h3>JavaScript</h3>
<pre><code style="font-size: 10px;" class="prettyprint">angular.module('app', ['ngUiMultiSelect'])
.controller('ctrl', function($scope, $timeout, $http){
$scope.getOptions = function(viewValue){
return $http.get('https://jsonplaceholder.typicode.com/users?q='+viewValue)
.then(function(resp){
$scope.items = resp.data;
})
}
})</code></pre>
</div>
</div>
</div>
</main>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.min.js"></script>
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
<script type="text/javascript" src="dist/ng-ui-multi-select.js"></script>
<script type="text/javascript">
angular.module('app', ['ngUiMultiSelect']).controller('ctrl', function($scope, $timeout, $http){
$scope.funcionarios = [];
$scope.onSelect = function(value){
console.log(value);
}
$scope.onRemove = function(value){
console.log(value);
}
$scope.getOptions = function(viewValue){
return $http.get('https://jsonplaceholder.typicode.com/users?q='+viewValue)
.then(function(resp){
$scope.items = resp.data;
})
}
})
</script>
</body>
</html>