Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/select2.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,21 @@ angular.module('ui.select2', []).value('uiSelect2Config', {}).directive('uiSelec
});
}

var initial_render;

if (attrs.uiSelect2) {
scope.$watch(attrs.uiSelect2, function (newVal) {
if (initial_render !== undefined) {
$timeout.cancel(initial_render);
};
angular.extend(opts, newVal);
elm.select2(opts);
controller.$render();
}, true);
}

// Initialize the plugin late so that the injected DOM does not disrupt the template compiler
$timeout(function () {
initial_render = $timeout(function () {
elm.select2(opts);

// Set initial value - I'm not sure about this but it seems to need to be there
Expand Down