gpt4 book ai didi

html - 在 AngularJS 的选择下拉列表中添加搜索过滤器

转载 作者:技术小花猫 更新时间:2023-10-29 12:50:13 27 4
gpt4 key购买 nike

我想在 angularJS 的选择下拉列表中添加一个搜索过滤器。

我已经使用 ng-options 列出选项并使用 filter 过滤掉搜索框中的数据,但问题是搜索框不在选择下拉列表中(或下方)。 (当我点击选择下拉菜单时,它会显示一个搜索过滤器,下面有所有选项)

以下是供您引用的代码:

<div class="rowMargin">
<label class="control-label" for="entitySel">Entity:</label>
<div class="controls">
<select id="entityId" class="input-medium" type="text" name="entityId" ng-model="payment.entityId" ng-options="entityOpt for entityOpt in paymentEntityOptions">
<option value="">Select</option>
</select>
<span ng-show=" submitted && addPayment.entityId.$error.required">
<label class="error">Please provide entity Id </label>
</span>
<div ng-show="payment.entityId == \'Individual\'">
<span>
<select ng-model="payment.entity.individual" ng-options = "individual for individual in individualEntities | filter : filterEntity">
<option value="">Select Individual Entity</option>
<option>
<input type="search" placeholder="Search" ng-model="filterEntity"></input>
</option>
</select>
</span>
</div>
<div ng-show="payment.entityId == \'Group\'">
<span>
<select ng-model="payment.entity.group" ng-options = "group for group in groupEntities | filter : filterEntity">
<option value="">Select Group Entity</option>
<input type="search" placeholder="Search" ng-model="filterEntity"></input>
</select>
</span>
</div>
</div>

最佳答案

我使用了类为“dropdown-toggle”的引导按钮,点击按钮后我添加了一个输入搜索框,如下所示:

<div class="dropdown pull-right makePaymentDropdownMainDiv" auto-close="outsideClick">
<button class="btn btn-default dropdown-toggle makePaymentDropdownBtn" type="button" id="individualDrop" data-toggle="dropdown">{{payment.entity}}<span class="caret pull-right"></span></button>
<span ng-show="submitted"><label class="error">Select an Individual</label></span>
<ul class="dropdown-menu makePaymentDropdownUlStyle" role="menu" aria-labelledby="individualDrop">
<input disable-auto-close type="search" ng-model="serchFilter" class="makePaymentDropdownSearchBox" placeholder="Search"></input>
<li role="presentation" ng-repeat="indi in individuals | filter: serchFilter"><a role="menuitem" ng-click="selectEntity(indi)">{{indi}}</a></li>
</ul>
</div>

使用 ng-repeat 显示“li”。

请记住将 auto-close="outsideClick"添加到您的下拉列表中,这样它就不会在尝试过滤时关闭。

关于html - 在 AngularJS 的选择下拉列表中添加搜索过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25550462/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com