如何在角度js中过滤和动态选择下拉列表 [英] How do I filter and dynamically select drop down list in angular js

查看:129
本文介绍了如何在角度js中过滤和动态选择下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have input text box to filter items from a dropdown Select list. 
This works fine. 

But there are two problems.

1. When data gets populated i want 1st item to be visible in dropdown.
2. As i type in filter box first matching among the list should be displayes in the dropdown control.

How do i achieve this?





我尝试过: < br $>




What I have tried:

My code


<input type="text" id="fromSearchBox" class="form-control w-auto h-25" ng-model="SearchEmployee" />
                                            <select class="form-control" ng-model="fromManagerInfo">
                                                <option ng-repeat="emp in employees|filter:SearchEmployee">{{emp.EmployeeInfo}}
                                                </option>
                                            </select>

推荐答案

您可以在ng-init上使用ng-model设置selectedItem



You can set the selectedItem using ng-model on ng-init

<input type="text" ng-init="SearchEmployee = employees[0]" id="fromSearchBox" class="form-control w-auto h-25" ng-model="SearchEmployee" />





和过滤器你已经在使用过滤器


这篇关于如何在角度js中过滤和动态选择下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆