diff --git a/README.md b/README.md
index 45a6517c..5137d69f 100644
--- a/README.md
+++ b/README.md
@@ -39,9 +39,7 @@ You can also use Bower to install all files at once. Just run `bower install ng-
.controller('MyCtrl', function($scope, $http) {
$scope.tags = ['just','some','cool','tags'];
$scope.loadTags = function(query) {
- return $http.get('/tags?query=' + query).then(function(response) {
- return response.data;
- });
+ return $http.get('/tags?query=' + query);
};
});
diff --git a/build/ng-tags-input.js b/build/ng-tags-input.js
index baff0cc0..2857fe93 100644
--- a/build/ng-tags-input.js
+++ b/build/ng-tags-input.js
@@ -53,7 +53,7 @@ tagsInput.directive('tagsInput', ["$timeout","$document","tiConfiguration", func
},
trigger: function(name, args) {
angular.forEach(events[name], function(handler) {
- handler.call(null, args);
+ handler.call(null, args);
});
}
};
@@ -298,9 +298,6 @@ tagsInput.directive('autoComplete', ["$document","$timeout","$sce","tiConfigurat
self.selected = null;
self.visible = true;
};
- self.hide = function() {
- self.visible = false;
- };
self.load = function(query, tags) {
if (query.length < options.minLength) {
self.reset();
@@ -319,7 +316,7 @@ tagsInput.directive('autoComplete', ["$document","$timeout","$sce","tiConfigurat
return;
}
- self.items = getDifference(items, tags);
+ self.items = getDifference(items.data || items, tags);
if (self.items.length > 0) {
self.show();
}
@@ -564,9 +561,10 @@ tagsInput.service('tiConfiguration', ["$interpolate", function($interpolate) {
};
}]);
+
+/* HTML templates */
tagsInput.run(["$templateCache", function($templateCache) {
-
- $templateCache.put('ngTagsInput/tags-input.html',
+ $templateCache.put('ngTagsInput/tags-input.html',
"
"
);
diff --git a/build/ng-tags-input.min.zip b/build/ng-tags-input.min.zip
index 9f9f0995..c0adab2a 100644
Binary files a/build/ng-tags-input.min.zip and b/build/ng-tags-input.min.zip differ
diff --git a/build/ng-tags-input.zip b/build/ng-tags-input.zip
index a271dfd0..28560b27 100644
Binary files a/build/ng-tags-input.zip and b/build/ng-tags-input.zip differ
diff --git a/src/auto-complete.js b/src/auto-complete.js
index 3d25f9b8..fe15071a 100644
--- a/src/auto-complete.js
+++ b/src/auto-complete.js
@@ -49,9 +49,6 @@ tagsInput.directive('autoComplete', function($document, $timeout, $sce, tiConfig
self.selected = null;
self.visible = true;
};
- self.hide = function() {
- self.visible = false;
- };
self.load = function(query, tags) {
if (query.length < options.minLength) {
self.reset();
@@ -70,7 +67,7 @@ tagsInput.directive('autoComplete', function($document, $timeout, $sce, tiConfig
return;
}
- self.items = getDifference(items, tags);
+ self.items = getDifference(items.data || items, tags);
if (self.items.length > 0) {
self.show();
}
diff --git a/test/auto-complete.spec.js b/test/auto-complete.spec.js
index ccecfba9..a6b2480e 100644
--- a/test/auto-complete.spec.js
+++ b/test/auto-complete.spec.js
@@ -111,6 +111,17 @@ describe('autocomplete-directive', function() {
expect(getSuggestionText(1)).toBe('Item2');
});
+ it('renders all elements returned by the load function that aren\'t already added ($http promise)', function() {
+ // Act
+ tagsInput.getTags.andReturn(['Item3']);
+ loadSuggestions({ data: ['Item1','Item2','Item3'] });
+
+ // Assert
+ expect(getSuggestions().length).toBe(2);
+ expect(getSuggestionText(0)).toBe('Item1');
+ expect(getSuggestionText(1)).toBe('Item2');
+ });
+
it('shows the suggestions list when there are items to show', function() {
// Act
loadSuggestions(['Item1']);