This repository was archived by the owner on Apr 30, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -33,13 +33,22 @@ export default ngModule => {
33
33
} ;
34
34
35
35
// initialize the checkboxes check property
36
- const modelValue = $scope . model [ opts . key ] ;
37
- if ( angular . isArray ( modelValue ) ) {
38
- const valueProp = to . valueProp || 'value' ;
39
- angular . forEach ( to . options , function ( v , index ) {
40
- $scope . multiCheckbox . checked [ index ] = modelValue . indexOf ( v [ valueProp ] ) !== - 1 ;
41
- } ) ;
42
- }
36
+ $scope . $watch ( 'model' , function modelWatcher ( newModelValue ) {
37
+ var modelValue , valueProp ;
38
+
39
+ if ( Object . keys ( newModelValue ) . length ) {
40
+ modelValue = newModelValue [ opts . key ] ;
41
+
42
+ $scope . $watch ( 'to.options' , function optionsWatcher ( newOptionsValues ) {
43
+ if ( newOptionsValues && Array . isArray ( newOptionsValues ) && Array . isArray ( modelValue ) ) {
44
+ valueProp = to . valueProp || 'value' ;
45
+ for ( var index = 0 ; index < newOptionsValues . length ; index ++ ) {
46
+ $scope . multiCheckbox . checked [ index ] = modelValue . indexOf ( newOptionsValues [ index ] [ valueProp ] ) !== - 1 ;
47
+ }
48
+ }
49
+ } ) ;
50
+ }
51
+ } , true ) ;
43
52
44
53
function checkValidity ( expressionValue ) {
45
54
var valid = angular . isArray ( $scope . model [ opts . key ] ) &&
You can’t perform that action at this time.
0 commit comments