From 4e9b6a5ce8bb932b422f372053141fac375ee295 Mon Sep 17 00:00:00 2001 From: Glenn Fowler Date: Thu, 29 May 2014 12:18:36 +1000 Subject: [PATCH] Angular 1.0.x compatability - Guard for controller.$setPristine --- src/select2.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/select2.js b/src/select2.js index 828032d..2424369 100644 --- a/src/select2.js +++ b/src/select2.js @@ -166,7 +166,7 @@ angular.module('ui.select2', []).value('uiSelect2Config', {}).directive('uiSelec var isPristine = controller.$pristine; controller.$setViewValue(convertToAngularModel(value)); callback(value); - if (isPristine) { + if (isPristine && controller.$setPristine) { controller.$setPristine(); } elm.prev().toggleClass('ng-pristine', controller.$pristine); @@ -210,7 +210,7 @@ angular.module('ui.select2', []).value('uiSelect2Config', {}).directive('uiSelec controller.$setViewValue( convertToAngularModel(elm.select2('data')) ); - if (isPristine) { + if (isPristine && controller.$setPristine) { controller.$setPristine(); } elm.prev().toggleClass('ng-pristine', controller.$pristine);