javascript - ng-model gets defaulted correctly, but select won't show the text, shows blank instead -


so, i'm trying read list of options server, , supply tag, first option default - important thing - i've got model being set correctly, in select shows blank!, , have no idea why that!

i've tried lot of soulations, here, here, , here.

view:-

<select ng-options="option option.name option in options track 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 selected being set correctly! help?

update1: seems problems compatibility between angular , jquery-mobile (not added me :@), knows that?

update2: when removing jquery.mobile.min.js, works fine. unfortunately, need throw out project.

update3: problem jqm produce span display value selected, , that's problem!, i've binded select, not span. problem can't bind span till now, 'cuase jqm generate span in runtime :( , that's why when commenting out jqm js works fine.

updated4: solved :d, solution given below future reference.

the problem jqm doesn't display selected value itself, instead gets selected value, , put span in run time, , hides select completely, trust me, took me > 12 hours learn hard way!

so in order jqm re-get selected value select , send displaying span, have call:

jquery("#selectid").selectmenu("refresh", true); 

notice in case you're using angular me, it's better use "jquery" not "$" avoid conflict between angular , jquery.

don't take 1 line solation lightly :d, cost more working day :d, hope helpful :d .

importent ref: here.

also note: can make angular directive if intend use select more once :d .


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -