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

Commit ac4a5df

Browse files
committed
updated examples
1 parent c9232e8 commit ac4a5df

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

examples/demo-tagging.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,16 @@ <h3>Tagging without multiple, with simple strings</h3>
140140
<p>Selected: {{singleDemo.color}}</p>
141141

142142

143+
<h3>Tagging without multiple with label and complex objects</h3>
144+
<ui-select tagging="convertToPerson" on-select="onSelect($item, $model)" ng-model="person.selected" ng-disabled="disabled" title="Choose a person" style="width: 800px;">
145+
<ui-select-match placeholder="Selecione um cliente">{{$select.selected.name}}</ui-select-match>
146+
<ui-select-choices repeat="person in people | propsFilter: {name: $select.search} track by person.name" >
147+
<div ng-if="person.isTag" ng-bind-html="person.name +' <small>(new)</small>'"></div>
148+
<div ng-if="!person.isTag" ng-bind-html="person.name | highlight: $select.search"></div>
149+
</ui-select-choices>
150+
</ui-select>
151+
<p>Selected: {{person.selected}}</p>
152+
143153
<div style="height:500px"></div>
144154

145155
</body>

examples/demo.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ app.filter('propsFilter', function() {
1414

1515
if (angular.isArray(items)) {
1616
var keys = Object.keys(props);
17-
17+
1818
items.forEach(function(item) {
1919
var itemMatches = false;
2020

@@ -130,6 +130,7 @@ app.controller('DemoCtrl', function($scope, $http, $timeout, $interval) {
130130
return item;
131131
};
132132

133+
133134
$scope.peopleObj = {
134135
'1' : { name: 'Adam', email: '[email protected]', age: 12, country: 'United States' },
135136
'2' : { name: 'Amalie', email: '[email protected]', age: 12, country: 'Argentina' },
@@ -143,6 +144,24 @@ app.controller('DemoCtrl', function($scope, $http, $timeout, $interval) {
143144
'10' : { name: 'Nicolás', email: '[email protected]', age: 43, country: 'Colombia' }
144145
};
145146

147+
$scope.convertToPerson = function (newPersonName) {
148+
var person = {
149+
name: newPersonName
150+
};
151+
152+
return person;
153+
};
154+
155+
$scope.onSelect = function($item, $model){
156+
if(!$item.isTag){
157+
return false;
158+
}
159+
var item = angular.copy($item);
160+
delete item.isTag;
161+
162+
$scope.people.push(item);
163+
};
164+
146165
$scope.person = {};
147166

148167
$scope.person.selectedValue = $scope.peopleObj[3];

0 commit comments

Comments
 (0)