Data Browser - Viewing Site  Sector 23 Code Bank Logged in as:  Guest  


Angular drop down select item with null value
In Angular, a new item with 'null' value is created in ng-options dropdown if you bind to a list where your value isn't included.
If your value is included, the 'null' option isn't created, so you have to manually insert it into your list:
$, 0, {Id:null,Title:''});

But if your value is 'null', the extra item still gets added, so now you have two blank items.

The way around this is to manually add your blank item, and then remove the angular item by adding ng-if="false" to an option matching the angular item:

<select ng-options="e.Id as e.Title for e in data" ng-model="selValue">
<option value="" ng-if="false"></option>

Created By: amos 11/11/2015 2:16:02 PM
Updated: 11/11/2015 2:16:52 PM