I have implemented angular-ui-select
for dropdowns and I want to include a cancel feature in the dropdown.
This is the dropdown structure in my template:
<select ui-select2="select2Options" name="Machine" ng-model="selectedMachine.type" data-placeholder="type" required>
<option value=""></option>
<option ng-repeat="type in machineTypes" value="{{type}}">{{type}}</option>
</select>
Here are the select2Options
settings:
$rootScope.select2Options = {
minimumResultsForSearch: 5,
allowClear: true,
...
}
Upon implementation, the result looks like this:
https://i.sstatic.net/Fatgc.png
https://i.sstatic.net/LAImM.png
One issue I encountered is the presence of empty fields due to having
, which is causing unexpected behavior.<option value=""></option>
Removing
<option value=""></option>
resolves the empty field problem, but it also removes the cancel button from the dropdown:https://i.sstatic.net/9G5nm.png
What steps should I take to ensure the presence of a cancel button without having empty fields?
angular: v1.4.8
angular-ui-select2: v0.0.5
select2: v3.4