我如何创建一个可编辑的下拉菜单,用户可以在其中添加一个新选项。
你可以在下面找到我的html下拉代码:
<select class="fieldDropdown" ng-model="currentFileGroup" title="" ng-options="value.ls_ItemValue as value.ls_ItemText for (key, value) in formLIST.filesGroup" data-style=""></select>我想当用户填写选项时,它会自动添加到数据库中。 使用JavaScript,AngularJS或jQuery没有问题。
How I can create an editable drop down, that user can add a new option inside that with filling that.
You can find my html drop down code in below:
<select class="fieldDropdown" ng-model="currentFileGroup" title="" ng-options="value.ls_ItemValue as value.ls_ItemText for (key, value) in formLIST.filesGroup" data-style=""></select>I want when a user filled the option, it automatically added to the database. There is no problem to using JavaScript, AngularJS or jQuery.
最满意答案
我通常使用ui-select进行这种交互: https : //github.com/angular-ui/ui-select
在这种情况下,“标记”功能可能最接近您想要的功能: http : //plnkr.co/edit/m1SQXUxftBLQtitng1f0?p = preview
<ui-select tagging="tagTransform" ng-model="person.selected" theme="bootstrap" ng-disabled="disabled" style="width: 800px;" title="Choose a person"> <ui-select-match placeholder="Select person...">{{$select.selected.name}} <{{$select.selected.email}}></ui-select-match> <ui-select-choices repeat="person in people | propsFilter: {name: $select.search, age: $select.search}"> <div ng-if="person.isTag" ng-bind-html="person.name +' <small>(new)</small>'| highlight: $select.search"></div> <div ng-if="!person.isTag" ng-bind-html="person.name + person.isTag| highlight: $select.search"></div> <small> email: {{person.email}} age: <span ng-bind-html="''+person.age | highlight: $select.search"> </span> </small> </ui-select-choices> </ui-select> <p>Selected: {{person.selected}}</p>I usually use ui-select for this sort of interaction: https://github.com/angular-ui/ui-select
The 'tagging' feature probably gets closest to what you'd want in this case: http://plnkr.co/edit/m1SQXUxftBLQtitng1f0?p=preview
<ui-select tagging="tagTransform" ng-model="person.selected" theme="bootstrap" ng-disabled="disabled" style="width: 800px;" title="Choose a person"> <ui-select-match placeholder="Select person...">{{$select.selected.name}} <{{$select.selected.email}}></ui-select-match> <ui-select-choices repeat="person in people | propsFilter: {name: $select.search, age: $select.search}"> <div ng-if="person.isTag" ng-bind-html="person.name +' <small>(new)</small>'| highlight: $select.search"></div> <div ng-if="!person.isTag" ng-bind-html="person.name + person.isTag| highlight: $select.search"></div> <small> email: {{person.email}} age: <span ng-bind-html="''+person.age | highlight: $select.search"> </span> </small> </ui-select-choices> </ui-select> <p>Selected: {{person.selected}}</p>更多推荐
发布评论