Hi, I am looking at similar Razor views in the solution to see how to populate a select with live search. Below is the code. The problem is the select control is never populated, instead it shows "Nothing Selected".
I made sure data is returned from server. I can see them on the Chrome Developer Tool.
Thanks
View:
<select class="form-control bs-select" name="Shelter" id="Shelter" ng-model="vm.poc.shelter"
ui-jq="selectpicker"
data-live-search="true">
<option ng-repeat="shelter in vm.shelters"
value="{{shelter.id}}">{{shelter.label}}
</option>
</select>
<label>@L("Shelter")</label>
Controller:
vm.shelters = [];
vm.init = function () {
vm.loading = true;
commonLookupService.getReferenceTables().then(function (result) {
vm.shelters = result.data.shelters;
}).finally(function () {
vm.loading = false;
});
}
vm.init();
5 Answer(s)
-
0
Hi,
I think you need to refresh selectpicker after getting data from server. There are examples in the project, you can check them.
Thanks.
-
0
That is correct if I am using ng-options to bind elements, but in my case I am just looping over items.
Check App/common/views/languages/texts.cshtml
-
0
Hi,
I couldn't be sure at the moment. Have you tried refreshing anyway ? It is simple to try.
Thanks.
-
0
Maybe I was mistaken, a refresh is needed and it works now.
Although in the texts.cshtnl, the languages array is set to static values in the controller and it shows without problems, however, the source names because they are loaded from db, a refresh was used.
Thanks
-
0
Thanks, great :)