Click here to Skip to main content
15,891,633 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?


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>
Posted
Updated 11-Jun-18 15:06pm

1 solution

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" />


and for filter you are already using the filter
 
Share this answer
 
Comments
istudent 11-Jun-18 23:49pm    
This behaves same. It do not pre-select the items from list as it filters.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900