/combobox

Angular module with custom combobox directive

Primary LanguageJavaScriptGNU General Public License v3.0GPL-3.0

Combobox

This is simple angular module that contains directive for creating combobox with typeahead form control. The typeahead is very flexible and easy to use. It has fuzzy search and acts like a dropdown. You simply need to include the angular module dependency, define your options and start using it. In this project you can find simple example of the setup and usage of this typeahead form control. First you need to define the controller, include the dependency and create the options list:

var module = ng.module('MyApp', ['typeahead']);

module.controller('MyCtrl', ['$scope', function($scope){
	$scope.options = ['Option 1', 'Option 2', 'Option 3'];
}]);

Then in your view you use it like this:

<input type="text" 
   class="combobox"
   ng-model="selectedOption"
   placeholder="Select option"
   data-options="options"/>

The placeholder is what will be used for the replacement input generated by the directive. The class "combobox" is what triggers the directive. The data-options is the list with options added to the scope of your controller.

Notes

In order to test the example you need to run it through http server rooted at the folder of the projects so that the directive template is correctly resolved.

This example was tested with the help of the python http server module.