diff options
author | isteven <ignatius.steven@gmail.com> | 2014-05-17 08:27:00 +0800 |
---|---|---|
committer | isteven <ignatius.steven@gmail.com> | 2014-05-17 08:27:00 +0800 |
commit | 2ef3dc3f4413455c3050cd09c7e77d376671f8b4 (patch) | |
tree | 6a17817f82be299435cb6574a77ca9adc645030b /angular-multi-select.js | |
parent | 2865bd8f8625e054f27488c2928cf9e700645a9a (diff) | |
download | angular-multi-select-2ef3dc3f4413455c3050cd09c7e77d376671f8b4.zip angular-multi-select-2ef3dc3f4413455c3050cd09c7e77d376671f8b4.tar.gz angular-multi-select-2ef3dc3f4413455c3050cd09c7e77d376671f8b4.tar.bz2 |
allow granular input-model update
Diffstat (limited to 'angular-multi-select.js')
-rw-r--r-- | angular-multi-select.js | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/angular-multi-select.js b/angular-multi-select.js index 1197874..e8e0ce8 100644 --- a/angular-multi-select.js +++ b/angular-multi-select.js @@ -394,15 +394,27 @@ angular.module( 'multi-select', ['ng'] ).directive( 'multiSelect' , [ '$sce', '$ validate(); $scope.refreshSelectedItems(); - // Watch for changes in input model (allow dynamic input) + // Watch for changes in input model + // Updates multi-select when user select/deselect a single checkbox programatically + // https://github.com/isteven/angular-multi-select/issues/8 $scope.$watch( 'inputModel' , function( oldVal, newVal ) { - if ( $scope.inputModel !== 'undefined' ) { + if ( $scope.newVal !== 'undefined' ) { + validateProperties( $scope.itemLabel.split( ' ' ), $scope.inputModel ); + validateProperties( new Array( $scope.tickProperty ), $scope.inputModel ); + } + $scope.refreshSelectedItems(); + }, true); + + // Watch for changes in input model + // This on updates the multi-select when a user load a whole new input-model. We also update the $scope.backUp variable + $scope.$watch( 'inputModel' , function( oldVal, newVal ) { + if ( $scope.newVal !== 'undefined' ) { validateProperties( $scope.itemLabel.split( ' ' ), $scope.inputModel ); validateProperties( new Array( $scope.tickProperty ), $scope.inputModel ); } $scope.backUp = angular.copy( $scope.inputModel ); $scope.refreshSelectedItems(); - }); + }); // Watch for changes in directive state (disabled or enabled) $scope.$watch( 'isDisabled' , function( newVal ) { |