I'm trying to build double select with null option.
One select is filtered according to the first select chosen option. The problem I have is I want to keep the first 'null' row even after filter.
I've made a plunker based on solution of null option I saw. Here's the plunker: demo
I am trying to select a country and in the cities, keep the 'null' option (anyCity) as a selectable option. What is the best approach to achieve this?
(My original problem consists of double filter--> selecting a city also filtering the country)
Html:
<body ng-controller="DemoCtrl">
<h3>Countries</h3>
<p>Selected: {{country.selected || (country.selected === null ? 'null' : '')}}</p>
<ui-select ng-model="country.selected" theme="bootstrap" ng-disabled="disabled" style="width: 300px;">
<ui-select-match placeholder="Select or search a country in the list...">{{$select.selected.name}}</ui-select-match>
<ui-select-choices repeat="country in countries | filter: $select.search" null-option="anyCountry">
<span ng-bind-html="country.name | highlight: $select.search"></span>
<small ng-bind-html="country.code | highlight: $select.search"></small>
</ui-select-choices>
</ui-select>
<h3>Cities</h3>
<p>The loose-null option treats undefined the same as null.</p>
<p>Selected: {{country2.selected || (country2.selected === null ? 'null' : '')}}</p>
<ui-select ng-model="country2.selected" theme="bootstrap" ng-disabled="disabled" style="width: 300px;">
<ui-select-match placeholder="Select or search a city in the list...">{{$select.selected.name}}</ui-select-match>
<ui-select-choices repeat="city in cities | filter: {country: country.selected.code}" null-option="anyCity" loose-null>
<span ng-bind-html="city.name | highlight: $select.search"></span>
<small ng-bind-html="city.code | highlight: $select.search"></small>
</ui-select-choices>
</ui-select>
</body>
</html>