I have a UI requirement where a user needs to be able to click on an element, display its options, and the options are checkbox inputs.
So, a 'select' element that allows multiple checkbox inputs.
<div class="select-custom" ng-click="selectToggle = !selectToggle">
<div ng-show="all(x)">All Options<span class="arr"></span></div>
<div ng-show="!all(x) && !notAllowed(x)">Selected Options<span class="arr"></span></div>
<div ng-show="notAllowed(x)">No Options Selected<span class="arr"></span></div>
</div>
<ul class="list-unstyled select-custom-options" ng-show="selectToggle">
<li ng-repeat="option in options">
<input type="checkbox" value="{{option.Name}}" ng-model="option.Allow">{{option.Name}}
</li>
</ul>
The div
is styled like a select input and the ul
contains the options. Everything works well, except that you need to click the div in order to hide the ul
. Normally, a select element will close if you click outside the options.
Suggestions on how to add that behavior to an element like this?