In my project, there are many dropdownlist. Items of those dropdownlist are loaded from database using api service. So, whenever it is loaded that blank option comes first of all items. How to remove that first blank option and replace with default text selection.
Controller
$scope.EnclosureModel = "";
loadEnclosure();
function loadEnclosure()
{
$scope.loading = true;
var promise = ngservice.getClosureType();
promise.then(function (resp) {
$scope.EnclosureList = resp.data;
$scope.loading = false;
});
}
api calls consumes by angular service method
service
this.getClosureType = function () {
var res = $http.get("/api/Surge/GetEnclosure");
return res;
};
Here is my View:
Enclosure type
<a href="#" onclick="return false;" rel="EnclosureType">
<img src="img/question.jpg" Border="0" style="vertical-align:middle; width:16px;" />
</a>
<br />
<select ID="Drp_EnclosureType_Option1" AutoPostBack="True" Class="form-control form-control-small" ng-model="EnclosureModel" ng-options="p for p in EnclosureList" ng-change="getConf();getNoCurr();getMaxCur();getMScr();getLoc();getIec();getmCOV();getsysV();getIncidents();getRemSignals();getalr();getRejc();getCount();">
<option Value ="" selected="selected">--Select--</option>
</select>
Items are loaded properly from database but every time that blank option is on first.After checking so many post i have tried many things. Last one i tried
$scope.EnclosureModel={"selected":null}
It removed the first blank perfectly but problem is that other dropdownlist will be changing based on this "ENCLOSURE" dropodownlist's item selection. So when ever i tried with above other dropdown lists are changed and having null items.
I know angular model behaves like this because of undefined value when no items are selected.
But how to remove the first blank from option where data is loaded by api service.