用数据键入下拉角度js

时间:2016-11-14 10:04:15

标签: javascript angularjs angularjs-filter

我是棱角分明的新手。我有一个下拉列表,其中包含超过150个值。我想搜索随附的下拉列表。所以,我尝试了所有的事情,但我无法做到。所以,我的代码是 -

HTML -

<div class="select-container col-sm-12 label-container"
                            ng-disabled="!objectPropertyForm.selectedObjectProperty">
                            <span class="col-sm-4 text-right label-container">
                                <label>Value : </label>
                            </span>
                            <span class="col-sm-8">
                                <select
                                    id="objectPropertyValueSelect"
                                    name="objectPropertyValue"
                                    class="btn btn-start col-sm-12"
                                    ng-model="objectPropertyForm.selectedObjectPropertyValue"
                                    ng-options="range as range.name for range in objectPropertyForm.selectedObjectProperty.rangeList |
                                        filter:objectPropertyRangeFilter
                                        track by range.name">
                                      <option value="" disabled selected>Select your option</option>
                                </select>
                            </span>
                    </div>

控制器 -

 $scope.objectPropertyRangeFilter = function (value) {
                    return !($scope.objectPropertyForm.selectedObjectProperty
                        .values.includes(value.name));
                };

如果在输入时给出了值,我想只有那些存在键入文本的名称。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

你可以试试 https://material.angularjs.org/latest/demo/autocomplete 类似的解决方案

或转到https://github.com/darylrowland/angucomplete

您必须提供$ scope.localdata =您的autofilldata