如何动态加载模型angularjs选择组合框

问题描述 投票:0回答:1

此刻我有一个combo box。在我的appservice中,我查询数据库并获得前十名。

<select id="StationSelectionCombobox"
        name="Country"
        ng-options="s.amenityUID as s.amenityName for s in  vm.nearbyStations"
        ng-model="vm.stations[$index].amenityUID"
        ng-change="vm.updateStation($index)"
        class="form-control bs-select drop-down"
        ui-jq="selectpicker">
    <option value="">@L("NotSelected")</option>
</select>

随着输入字符,我正在寻找动态更新模型的方法。请问我应该怎么做,或者这种控制是否还可以。

angularjs combobox angular-ui-select angularjs-select2 angularjs-select
1个回答
0
投票

Combo boxes不是HTML4或AngularJS的本机。它们需要第三方库或自定义指令。

考虑使用这些库:

  • [ui-select2指令,可以与ngModelController,ng-model和验证指令,例如ng-required很好地配合使用。
  • [ui-selectSelect2的AngularJS本机版本。

Selectize元素用作组合框

HTML5具有<datalist>元素,可以用作组合框:

<datalist>

有关更多信息,请参阅

  • <label for="ice-cream-choice">Choose a flavor:</label> <input list="ice-cream-flavors" id="ice-cream-choice" name="ice-cream-choice" ng-model="flavorChoice" /> <datalist id="ice-cream-flavors"> <option ng-repeat="choice in choicesArr | filter : flavorChoice | limitTo : 5" ng-value="choice"> </option> </datalist>
© www.soinside.com 2019 - 2024. All rights reserved.