1

is it possible to hide the <select> element if the ng-options variables are empty after using a filter?

<select class="form-control" 
        ng-model="selected" 
        ng-options="property.pstSnr.description for property in leistobToProperties | filter: {grouping:1}">
</select>

The <select> element should not be visible if all the options of property.pstSnr.description are empty.

Thanks.

3 Answers 3

2

You can define your filtered list and then use it in an ng-show:

<select class="form-control" 
        ng-show="filteredSet" 
        ng-model="selected"
        ng-options="property.pstSnr.description for property in filteredSet = (leistobToProperties | filter: filtering)">
</select>

JS Fiddle

Sign up to request clarification or add additional context in comments.

Comments

0

maybe

<select class="form-control" ng-model="selected" ng-show="filtered.pstSnr.description.length > 0" ng-options="property.pstSnr.description for property in filtered = (leistobToProperties | filter: {grouping:1})"></select>

Comments

0

I have a select as well hidden if there are no options

<select id="categorylist" focus-on="focusMe" ng-change="UpdateDowntimeEvent()" class="col-md-11" name="CategoryId" ng-model="Model.CurrentDowntime.CategoryId" ng-options="downtimeCategory.CategoryId as downtimeCategory.CategoryName group by downtimeCategory.Node  for downtimeCategory in Model.DowntimeCategories" required="" ng-hide="Model.DowntimeCategories ==0" >

You can try this

<select class="form-control" ng-model="selected" ng-options="property.pstSnr.description for property in leistobToProperties | filter: {grouping:1}" ng-hide=" property.leistobToProperties == 0"></select>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.