Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Watch config object #222

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
bower_components
demo/bower_components
demo/bower_components
.tern-port
10 changes: 9 additions & 1 deletion src/select2.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ angular.module('ui.select2', []).value('uiSelect2Config', {}).directive('uiSelec
// Set the view and model value and update the angular template manually for the ajax/multiple select2.
elm.bind("change", function (e) {
e.stopImmediatePropagation();

if (scope.$$phase || scope.$root.$$phase) {
return;
}
Expand Down Expand Up @@ -188,6 +188,14 @@ angular.module('ui.select2', []).value('uiSelect2Config', {}).directive('uiSelec
elm.select2('readonly', !!value);
});

if(attrs.uiSelect2) {
scope.$watch(attrs.uiSelect2, function(newVal) {
if(newVal) {
elm.select2(angular.extend({}, options, scope.$eval(attrs.uiSelect2)));
}
});
}

if (attrs.ngMultiple) {
scope.$watch(attrs.ngMultiple, function(newVal) {
attrs.$set('multiple', !!newVal);
Expand Down
2 changes: 1 addition & 1 deletion test/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = function(config) {
// list of files / patterns to load in the browser
files: [
// Dependencies
'bower_components/jquery/jquery.js',
'bower_components/jquery/dist/jquery.js',
'bower_components/angular/angular.js',
'bower_components/angular-mocks/angular-mocks.js',
'bower_components/select2/select2.js',
Expand Down