From 6470b48ce022885551e83c9f5fd8a90fbc6ff80e Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Fri, 16 Apr 2010 17:03:06 -0700 Subject: validation issues fixed --- angular-debug.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'angular-debug.js') diff --git a/angular-debug.js b/angular-debug.js index c3971b35..83ff265f 100644 --- a/angular-debug.js +++ b/angular-debug.js @@ -2839,7 +2839,7 @@ foreach({ element.removeClass('ng-input-indicator-wait'); scope.$invalidWidgets.markValid(element); } - element.data('$validate')(input); + element.data('$validate')(); scope.$root.$eval(); }); } else if (inputState.inFlight) { @@ -3202,6 +3202,11 @@ function valueAccessor(scope, element) { required = required || required === ''; if (!validator) throw "Validator named '" + validatorName + "' not found."; function validate(value) { + var force = false; + if (isUndefined(value)) { + value = element.val(); + force = true; + } if (element[0].disabled || isString(element.attr('readonly'))) { elementError(element, NG_VALIDATION_ERROR, null); invalidWidgets.markValid(element); @@ -3211,8 +3216,8 @@ function valueAccessor(scope, element) { validateScope = extend(new (extend(function(){}, {prototype:scope}))(), {$element:element}); error = required && !trim(value) ? "Required" : - validator({state:validateScope, scope:{get:validateScope.$get, set:validateScope.$set}}, value); - if (error !== lastError) { + (trim(value) ? validator({state:validateScope, scope:{get:validateScope.$get, set:validateScope.$set}}, value) : null); + if (error !== lastError || force) { elementError(element, NG_VALIDATION_ERROR, error); lastError = error; if (error) @@ -3621,14 +3626,12 @@ angularService('$route', function(location, params){ } }; function updateRoute(){ - console.log('updating route'); var childScope; $route.current = null; angular.foreach(routes, function(routeParams, route) { if (!childScope) { var pathParams = matcher(location.hashPath, route); if (pathParams) { - console.log('new route', routeParams.template, location.hashPath, location.hash); childScope = angular.scope(parentScope); $route.current = angular.extend({}, routeParams, { scope: childScope, -- cgit v1.2.3