diff --git a/examples/demo-tagging.html b/examples/demo-tagging.html index b2cc6cf7ad..fa732f920c 100644 --- a/examples/demo-tagging.html +++ b/examples/demo-tagging.html @@ -116,6 +116,21 @@

Object Tags with Tokenization (Space, Forward Slash, Comma)

Selected: {{multipleDemo.selectedPeople2}}

+

Tagging without multiple

+ + {{$select.selected.name}} <{{$select.selected.email}}> + +
+
+ + email: {{person.email}} + age: + +
+
+

Selected: {{person.selected}}

+ +
diff --git a/examples/demo.js b/examples/demo.js index 96fe294fb0..6fa1403465 100644 --- a/examples/demo.js +++ b/examples/demo.js @@ -153,6 +153,13 @@ app.controller('DemoCtrl', function($scope, $http, $timeout) { }); }; + $scope.addPerson = function(item, model){ + if(item.hasOwnProperty('isTag')) { + delete item.isTag; + $scope.people.push(item); + } + } + $scope.country = {}; $scope.countries = [ // Taken from https://gist.github.com/unceus/6501985 {name: 'Afghanistan', code: 'AF'}, diff --git a/src/select.js b/src/select.js index 1bf42b0978..400dc63477 100644 --- a/src/select.js +++ b/src/select.js @@ -420,7 +420,7 @@ } } // search ctrl.selected for dupes potentially caused by tagging and return early if found - if ( ctrl.selected && ctrl.selected.filter( function (selection) { return angular.equals(selection, item); }).length > 0 ) { + if ( ctrl.selected && angular.isArray(ctrl.selected) && ctrl.selected.filter( function (selection) { return angular.equals(selection, item); }).length > 0 ) { ctrl.close(skipFocusser); return; } @@ -837,24 +837,26 @@ } function _findApproxDupe(haystack, needle) { - var tempArr = angular.copy(haystack); var dupeIndex = -1; - for (var i = 0; i