Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Editable ComboBox using bootstrap/angularjs

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.

thanks

like image 440
sudhirk Avatar asked Feb 07 '14 13:02

sudhirk


1 Answers

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:

http://jsfiddle.net/ruslans_uralovs/2brhd/1/

<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>
                        </ul>
                    </div>
                </div>
        </div>
    </div>
</div>

Greetings from Ireland!

like image 148
Ruslans Uralovs Avatar answered Nov 11 '22 15:11

Ruslans Uralovs