So, I'm trying to read a list of options from the server, and supply it to tag, with the first option as default - which is really important thing to do - but all I've got is the model is being set correctly, but in the select it shows blank!, and I have no idea why is that!
I've tried a lot of SO soulations, here, here, and here.
view:-
<select ng-options="option as option.Name for option in options track by option.ID" ng-model="selected">
controller:-
DataService.getOptionsFromServer().then(function (result) {
//console.log(result.data);
$scope.options = result.data;
$scope.selected = $scope.options[0];
console.log($scope.selected);
}, function (err) {
console.error(err);
});
the
console.log($scope.selected);
shows that the selected is being set correctly! any help?
Update1: Seems the problems is compatibility between angular and jquery-mobile (not added by me :@), anybody knows something about that?
Update2: when removing jquery.mobile.min.js, it works fine. unfortunately, I need it throw out the project.
Update3: the problem is that JQM produce a span to display the value selected, and that's the problem!, I've binded the select, not the span. the problem is that I can't bind the span till now, 'cuase JQM generate the span in the runtime :( , that's why when commenting out the JQM js it works fine.
Updated4: solved :D, solution given below for future reference.