Reputation: 923
I have an angular web app that has the following:
<select ng-model="modelObject.users" ng-options="users.name for users in ajaxData">
</select>
and a controller which populates the select through ajax data. The problem I am having is that the data in the select does not get populated until the select is clicked on and then unfocused. After this the select will have all of the populated data when clicked on again.
Is this a bug or is there some reason the data/options are not being initially inserted into the select object.
I have tried to do something similar to this: angular.js select doesn't show the option value in the begining and have looked through many other questions on stack overflow. My issue is different in the fact that:
There are NO options in the select at all until a user clicks the select and un focuses it. Where as most other answers are in regards to just the top option not being initially selected.
Upvotes: 0
Views: 150
Reputation: 184
Initialize the ng-model of select tag, that will display the option on dropdown.
Upvotes: 0
Reputation: 507
Assuming you are using jquery to get the data, In your Ajax success handler, once you update your scope variable with your response data, use
$scope.$apply()
,
this should update the view with your data.
Upvotes: 2