Hi, I am using bootstrap-select in an angular js project.
Loading data inside the select control works fine. Now it is time to set a value from backend angular js.
The problem is the angular model is changing, but the change is not reflected on the client UI. Here is the code.
...
vm.poc = poc;
//Refresh all selects
refreshSelects();
var selectIds = {
shelters: '#Shelter',
...
};
function refreshSelects() {
//Loop over all select ids from the selectIds
//and trigger a refresh
.each(selectIds, function (value) {
$timeout(function () {
$(value).selectpicker('refresh');
}, 0);
});
}
5 Answer(s)
-
0
Hi,
Can you share the html part for your select item ?
Thanks.
-
0
Hi Ismail,
The problem was the bootstrap-select expects values to be "strings". In my case, I retrieve the value as Int from the server. I had to convert those values to strings, then they work fine. Is that normal?
Something else I got, the form was hanging and getting angular errors of infinite $digest cycles. I was creating functions to control ng-show, and inside those functions I am resetting fields to be hidden, but that was causing many $digest cycles. How would I control show/hide and when hidden to clear the value so that it doesn't get submitted to server?
Thanks
-
0
Hi,
Normally ng-show should work and invisible controls are not sent to server. Can you share a bit of code, so I will try to understand the cause of problem.
Thanks.
-
0
It's a huge form. I can share the application by email.
I read somewhere ng-if would remove the element from DOM, which is better so that the element will be submitted to server as empty.
The problem I believe is due to so many digest cycles.
Thanks
-
0
Please send the project and explain how can I reproduce the problem.
Thanks.