Created
February 23, 2013 22:48
-
-
Save mirontoli/5021701 to your computer and use it in GitHub Desktop.
Angular UI autocomplete example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var autocompleteApp = angular.module("autocompleteApp"); | |
var autocompleteController = function($scope) { | |
//http://jqueryui.com/autocomplete/ | |
var availableTags = [ | |
"ActionScript", | |
"AppleScript", | |
"Asp", | |
"BASIC", | |
"C", | |
"C++", | |
"Clojure", | |
"COBOL", | |
"ColdFusion", | |
"Erlang", | |
"Fortran", | |
"Groovy", | |
"Haskell", | |
"Java", | |
"JavaScript", | |
"Lisp", | |
"Perl", | |
"PHP", | |
"Python", | |
"Ruby", | |
"Scala", | |
"Scheme" | |
]; | |
$scope.autocompleteOptions = { | |
source: availableTags | |
} | |
} | |
autocompleteApp.('ui.config', { | |
autocomplete: { | |
minLength: 2, | |
delay: 500 | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head></head> | |
<body> | |
<div ng-app="autocompleteApp"> | |
Autocomplete: | |
<br> | |
<div ng-controller="autocompleteController"> | |
<input type="text" ui-autocomplete="autocompleteOptions"> | |
</div> | |
</div> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.1.3/angular.min.js"></script> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> | |
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js"></script> | |
<script src="ui/angular-ui.min.js"></script> | |
<script src="app.js"> | |
</script> | |
</body> | |
</html> |
Why would you do that? Just use the $http scope and create an http request.
Does it work when I use array of object in lieu of array of string?If not, how to work?plz.... very helpful to me if it work on array of object
angular.min.js:17 Uncaught Error: No module: autocompleteApp
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would it be sane to replace line 4 with a JQuery AJAX call to get a list of options from the server?