From 89b441fd5ea6cd97138147ccd79a574ce5ea277e Mon Sep 17 00:00:00 2001 From: Philipp Burgmer Date: Wed, 21 Sep 2016 13:43:57 +0200 Subject: [PATCH] fix(ngModel): use setValidity for Angular < 1.3 and $validators for >= 1.3 --- src/w11k-select.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/w11k-select.js b/src/w11k-select.js index 567f250..7a31a18 100644 --- a/src/w11k-select.js +++ b/src/w11k-select.js @@ -772,7 +772,14 @@ angular.module('w11k.select').directive('w11kSelect', [ controller.$render = render; controller.$formatters.push(external2internal); - controller.$validators.required = validateRequired; + if (angular.version.major === 1 && angular.version.minor < 3) { + controller.$parsers.push(function (viewValue) { + controller.$setValidity('required', validateRequired(viewValue)); + }); + } else { + controller.$validators.required = validateRequired; + } + controller.$parsers.push(internal2external);