diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Parser.js | 4 | ||||
| -rw-r--r-- | src/Validators.js | 29 |
2 files changed, 31 insertions, 2 deletions
diff --git a/src/Parser.js b/src/Parser.js index 3aa644ac..b59b21a7 100644 --- a/src/Parser.js +++ b/src/Parser.js @@ -349,11 +349,11 @@ Parser.prototype = { }, filter: function(){ - return this._pipeFunction(angular['filter']); + return this._pipeFunction(angularFilter); }, validator: function(){ - return this._pipeFunction(angular['validator']); + return this._pipeFunction(angularValidator); }, _pipeFunction: function(fnScope){ diff --git a/src/Validators.js b/src/Validators.js index 84681f15..b7efcb4a 100644 --- a/src/Validators.js +++ b/src/Validators.js @@ -77,5 +77,34 @@ foreach({ } catch (e) { return e.toString(); } + }, + + 'asynchronous': function(text, asynchronousFn) { + var stateKey = '$validateState'; + var lastKey = '$lastKey'; + var obj = this['$element']; + var stateCache = obj[stateKey] = obj[stateKey] || {}; + var state = stateCache[text]; + var updateView = this['$updateView']; + obj[lastKey] = text; + if (state === undefined) { + // we have never seen this before, Request it + jQuery(obj).addClass('ng-input-indicator-wait'); + state = stateCache[text] = null; + asynchronousFn(text, function(error){ + state = stateCache[text] = error ? error : false; + if (stateCache[obj[lastKey]] !== null) { + jQuery(obj).removeClass('ng-input-indicator-wait'); + } + updateView(); + }); + } + + if (state === null){ + // request in flight, mark widget invalid, but don't show it to user + this['$invalidWidgets'].push(this.$element); + } + return state; } + }, function(v,k) {angularValidator[k] = v;}); |
