mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-21 00:40:24 +00:00
fixed filter this
This commit is contained in:
parent
3d0b40fee2
commit
a8aa5af413
4 changed files with 28 additions and 22 deletions
23
angular-debug.js
vendored
23
angular-debug.js
vendored
|
|
@ -3124,7 +3124,8 @@ function valueAccessor(scope, element) {
|
|||
var validatorName = element.attr('ng-validate') || NOOP,
|
||||
validator = compileValidator(validatorName),
|
||||
required = element.attr('ng-required'),
|
||||
lastError;
|
||||
lastError,
|
||||
invalidWidgets = scope.$invalidWidgets || {markValid:noop, markInvalid:noop};
|
||||
required = required || required === '';
|
||||
if (!validator) throw "Validator named '" + validatorName + "' not found.";
|
||||
function validate(value) {
|
||||
|
|
@ -3132,6 +3133,10 @@ function valueAccessor(scope, element) {
|
|||
if (error !== lastError) {
|
||||
elementError(element, NG_VALIDATION_ERROR, error);
|
||||
lastError = error;
|
||||
if (error)
|
||||
invalidWidgets.markInvalid(element);
|
||||
else
|
||||
invalidWidgets.markValid(element);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
|
@ -3339,7 +3344,6 @@ angularWidget('NG:SWITCH', function ngSwitch(element){
|
|||
}
|
||||
}
|
||||
});
|
||||
console.log(regex);
|
||||
var match = on.match(new RegExp(regex));
|
||||
if (match) {
|
||||
foreach(params, function(name, index){
|
||||
|
|
@ -3438,6 +3442,21 @@ angularService("$hover", function(browser) {
|
|||
}
|
||||
});
|
||||
}, {inject:['$browser']});
|
||||
|
||||
angularService("$invalidWidgets", function(){
|
||||
var invalidWidgets = [];
|
||||
invalidWidgets.markValid = function(element){
|
||||
var index = indexOf(invalidWidgets, element);
|
||||
if (index != -1)
|
||||
invalidWidgets.splice(index, 1);
|
||||
};
|
||||
invalidWidgets.markInvalid = function(element){
|
||||
var index = indexOf(invalidWidgets, element);
|
||||
if (index === -1)
|
||||
invalidWidgets.push(element);
|
||||
};
|
||||
return invalidWidgets;
|
||||
});
|
||||
var browserSingleton;
|
||||
angularService('$browser', function browserFactory(){
|
||||
if (!browserSingleton) {
|
||||
|
|
|
|||
|
|
@ -372,16 +372,7 @@ Parser.prototype = {
|
|||
for ( var i = 0; i < argsFn.length; i++) {
|
||||
args.push(argsFn[i](self));
|
||||
}
|
||||
var pipeThis = function(){
|
||||
var _this = this;
|
||||
foreach(self, function(v, k) {
|
||||
if (k.charAt(0) == '$') {
|
||||
_this[k] = v;
|
||||
}
|
||||
});
|
||||
};
|
||||
pipeThis.prototype = self.self;
|
||||
return fn.apply(new pipeThis(), args);
|
||||
return fn.apply(self.state, args);
|
||||
};
|
||||
return function(){
|
||||
return fnInvoke;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ function valueAccessor(scope, element) {
|
|||
required = required || required === '';
|
||||
if (!validator) throw "Validator named '" + validatorName + "' not found.";
|
||||
function validate(value) {
|
||||
var error = required && !trim(value) ? "Required" : validator({self:scope, scope:{get:scope.$get, set:scope.$set}}, value);
|
||||
var error = required && !trim(value) ? "Required" : validator({state:scope, scope:{get:scope.$get, set:scope.$set}}, value);
|
||||
if (error !== lastError) {
|
||||
elementError(element, NG_VALIDATION_ERROR, error);
|
||||
lastError = error;
|
||||
|
|
@ -242,7 +242,6 @@ angularWidget('NG:SWITCH', function ngSwitch(element){
|
|||
}
|
||||
}
|
||||
});
|
||||
console.log(regex);
|
||||
var match = on.match(new RegExp(regex));
|
||||
if (match) {
|
||||
foreach(params, function(name, index){
|
||||
|
|
|
|||
|
|
@ -13,17 +13,14 @@ FiltersTest.prototype.XtestCurrency = function(){
|
|||
assertEquals(html.hasClass('ng-format-negative'), false);
|
||||
};
|
||||
|
||||
FiltersTest.prototype.XtestFilterThisIsContext = function(){
|
||||
expectAsserts(2);
|
||||
var scope = new Scope();
|
||||
Scope.expressionCache = {};
|
||||
scope.set('name', 'misko');
|
||||
var context = {$element:123};
|
||||
FiltersTest.prototype.testFilterThisIsContext = function(){
|
||||
expectAsserts(1);
|
||||
var scope = createScope();
|
||||
scope.name = 'misko';
|
||||
angular.filter.testFn = function () {
|
||||
assertEquals('Context not equal', 123, this.$element);
|
||||
assertEquals('scope not equal', 'misko', this.name);
|
||||
};
|
||||
scope.eval("0|testFn", context);
|
||||
scope.$eval("0|testFn");
|
||||
delete angular.filter['testFn'];
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue