From 8b56347e5d8697aca88e214334be0e1913c4826d Mon Sep 17 00:00:00 2001 From: "Ghislain B." Date: Fri, 6 Feb 2015 20:54:04 -0500 Subject: [PATCH 1/2] Fix $http AJAX request timing issue Making an $http (AJAX) request is giving timing issues, the bootstrap-select does not get refresh properly (or too early) and end up like an empty list because of timing issues. See the Issue #33 : https://github.com/joaoneto/angular-bootstrap-select/issues/33 Also the StackOverflow question and answer : http://stackoverflow.com/questions/28336106/angular-bootstrap-select-timing-issue-to-refresh/28376105#28376105 --- src/angular-bootstrap-select.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/angular-bootstrap-select.js b/src/angular-bootstrap-select.js index 67d80aa..091bb09 100644 --- a/src/angular-bootstrap-select.js +++ b/src/angular-bootstrap-select.js @@ -203,6 +203,10 @@ function selectpickerDirective($parse, $timeout) { if (attrs.ngModel) { scope.$watch(attrs.ngModel, refresh, true); } + + if (attrs.ngOptions && / in /.test(attrs.ngOptions)) { + scope.$watch(attrs.ngOptions.split(' in ')[1], refresh, true); + } if (attrs.ngDisabled) { scope.$watch(attrs.ngDisabled, refresh, true); From 69a99cdce484b13903263f2fa93808f55c7c1968 Mon Sep 17 00:00:00 2001 From: "Ghislain B." Date: Sun, 8 Feb 2015 23:59:57 -0500 Subject: [PATCH 2/2] Update angular-bootstrap-select.js --- src/angular-bootstrap-select.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/angular-bootstrap-select.js b/src/angular-bootstrap-select.js index 091bb09..9d98d2a 100644 --- a/src/angular-bootstrap-select.js +++ b/src/angular-bootstrap-select.js @@ -205,7 +205,7 @@ function selectpickerDirective($parse, $timeout) { } if (attrs.ngOptions && / in /.test(attrs.ngOptions)) { - scope.$watch(attrs.ngOptions.split(' in ')[1], refresh, true); + scope.$watch(attrs.ngOptions.replace('::', '').split(' in ')[1], refresh, true); } if (attrs.ngDisabled) {