Update switch.directive.js

the switch work failed! you should add listener on input,such as line 28~31.
pull/89/head
luqihang 2016-05-31 23:26:04 +08:00 committed by Vladimir Lugovsky
parent be74da99b5
commit 85181fd59d
1 changed files with 8 additions and 2 deletions

View File

@ -20,10 +20,16 @@
link: function (scope, elem, attr) { link: function (scope, elem, attr) {
$timeout(function(){ $timeout(function(){
scope.color = attr.color; scope.color = attr.color;
$(elem).find('input').bootstrapSwitch({ var input = $(elem).find('input');
input.bootstrapSwitch({
size: 'small', size: 'small',
onColor: attr.color onColor: attr.color
}); });
input.on('switchChange.bootstrapSwitch', function(event, state) {
scope.ngModel = state;
scope.$apply();
});
}); });
} }
}; };