@@ -17,7 +17,10 @@ angular.module('selectize', []).value('selectizeConfig', {}).directive("selectiz
1717 scope . config = scope . config || { } ;
1818
1919 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
2124 } ;
2225
2326 var toggle = function ( disabled ) {
@@ -44,16 +47,16 @@ angular.module('selectize', []).value('selectizeConfig', {}).directive("selectiz
4447 }
4548
4649 var setSelectizeValue = function ( ) {
50+ if ( ! angular . equals ( selectize . items , scope . ngModel ) ) {
51+ selectize . setValue ( scope . ngModel , true ) ;
52+ }
53+
4754 validate ( ) ;
4855
4956 selectize . $control . toggleClass ( 'ng-valid' , modelCtrl . $valid ) ;
5057 selectize . $control . toggleClass ( 'ng-invalid' , modelCtrl . $invalid ) ;
5158 selectize . $control . toggleClass ( 'ng-dirty' , modelCtrl . $dirty ) ;
5259 selectize . $control . toggleClass ( 'ng-pristine' , modelCtrl . $pristine ) ;
53-
54- if ( ! angular . equals ( selectize . items , scope . ngModel ) ) {
55- selectize . setValue ( scope . ngModel , true ) ;
56- }
5760 }
5861
5962 settings . onChange = function ( value ) {
0 commit comments