The function below comes from an angularjs controller and dynamically sets values for a dropdown, it works but the first option is always blank with a value of "?". How should I amend the function to either remove the blank option or set the selected option to items[0]?
--edit--
I haven't posted the full controller, which came from a 3rd party package, the controller shows the function u is called when the dropdown value changes.
There are 2 dropdowns, when one changes the other should update with new data, this part works but the new data has the extra blank option stated above.
thanks
function u() {
var subs;
if (n.model.alias == "group") {
var selectedGroup = document.getElementById("group").value;
subs = angular.element(document.getElementById('subGroup')).controller();
$.ajax({
url: "/umbraco/Api/ContentmentCustomApi/GetSubGroups",
type: "GET",
cache: false,
async: false,
data: { selectedGroup: selectedGroup }
}).then(function (data) {
subs.items = data;
});
};
}
<div class="contentment" ng-class="vm.uniqueId" ng-controller="Umbraco.Community.Contentment.DataEditors.DropdownList.Controller as vm">
<select id="{{model.alias}}" class="umb-dropdown" lk-html-attributes="vm.htmlAttributes" ng-model="model.value" ng-change="vm.change()" ng-options="item.value as item.name disable when item.disabled for item in vm.items">
</select>
</div>
model.value, is it part ofvm.items?