Home » Angularjs » Editable ComboBox using bootstrap/angularjs

Editable ComboBox using bootstrap/angularjs

Posted by: admin November 30, 2017 Leave a comment


I am not getting any solution for having combobox as select as well as input. That means if user selection in not there in per-populated list , then use should be able to enter his value of choice.
users choice (selected or entered) should be set and retrievable as ng-model in angularjs.



The ui-select2 library lets you use select2 through a directive. That provides some great UI elements that do what you’re asking for.

In general I also recommend the Angular Modules site to find various useful Angular libraries.


ui-select doesn’t really look like a proper select we are all used to.
So here is what i ended up doing with the help Twitter Bootstrap 3:


<div ng-app >
    <div class="row" ng-controller="ExampleController">
        <div class="col-xs-8 col-xs-offset-2">

            <form role="form">
                <div class="input-group">
                    <input type="text" class="form-control" ng-model="myColor.name">
                    <div class="input-group-btn">
                        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>
                        <ul id="color-dropdown-menu" class="dropdown-menu dropdown-menu-right" role="menu">
                            <li ng-repeat="color in colors" class="input-lg"><a href="#" ng-click="changeColor(color)">{{color.name}}</a></li>

Greetings from Ireland!


Using html5 you can do this:

    <input type=text list=browsers >
    <datalist id=browsers >
       <option> Google
       <option> IE9

Got it from here:


I also was looking for the same thing and didn’t find a good solution, so I ended up creating angular-combo-box directive which lets you do what you are looking for. Here’s an example.

angular.module('ngComboBoxExample', ['ngComboBox'])
  .controller('myController', function($scope) {
    $scope.options = [
    $scope.color = '';
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script src="http://bradleytrager.github.io/angular-combo-box/bower_components/angular-combo-box/dist/angular-combo-box.min.js"></script>

<div ng-app="ngComboBoxExample">
  <div ng-controller="myController">
    <combo-box options="options" combo-model="color" label="--Select a Color--" other-label="A color not on the list...">
    <div>Selected Color: <span ng-bind="color"></span>

Hope it helps!