@@ -17,7 +17,10 @@ angular.module('selectize', []).value('selectizeConfig', {}).directive("selectiz
17
17
scope . config = scope . config || { } ;
18
18
19
19
var isEmpty = function ( val ) {
20
- return val === undefined || val === null || ! val . length ; //support checking empty arrays
20
+ if ( angular . isArray ( val ) ) {
21
+ return ( val . length === 0 ) ;
22
+ }
23
+ return modelCtrl . $isEmpty ( val ) ; //call to real Angular function
21
24
} ;
22
25
23
26
var toggle = function ( disabled ) {
@@ -44,16 +47,16 @@ angular.module('selectize', []).value('selectizeConfig', {}).directive("selectiz
44
47
}
45
48
46
49
var setSelectizeValue = function ( ) {
50
+ if ( ! angular . equals ( selectize . items , scope . ngModel ) ) {
51
+ selectize . setValue ( scope . ngModel , true ) ;
52
+ }
53
+
47
54
validate ( ) ;
48
55
49
56
selectize . $control . toggleClass ( 'ng-valid' , modelCtrl . $valid ) ;
50
57
selectize . $control . toggleClass ( 'ng-invalid' , modelCtrl . $invalid ) ;
51
58
selectize . $control . toggleClass ( 'ng-dirty' , modelCtrl . $dirty ) ;
52
59
selectize . $control . toggleClass ( 'ng-pristine' , modelCtrl . $pristine ) ;
53
-
54
- if ( ! angular . equals ( selectize . items , scope . ngModel ) ) {
55
- selectize . setValue ( scope . ngModel , true ) ;
56
- }
57
60
}
58
61
59
62
settings . onChange = function ( value ) {
0 commit comments