I am trying to write an autocomplete directive that retrieves data from a server using a $ http request (without using any external plugins or scripts) . Currently, it only works with static data. Now I know that I need to insert my $ http request into the source: directive, but I cannot find good documentation on this.
http request
$http.post($scope.url, { "command": "list category() names"}). success(function(data, status) { $scope.status = status; $scope.names = data; }) . error(function(data, status) { $scope.data = data || "Request failed"; $scope.status = status; });
Directive
app.directive('autoComplete', function($timeout) { return function(scope, iElement, iAttrs) { iElement.autocomplete({ source: scope[iAttrs.uiItems], select: function() { $timeout(function() { iElement.trigger('input'); }, 0); } }); }; });
View
<input auto-complete ui-items="names" ng-init="manualcat='no category entered'" ng-model="manualcat">
So, how do I get Angular together?
Gidon Aug 27 '13 at 8:16 2013-08-27 08:16
source share