Я пытаюсь реализовать пользовательскую проверку с помощью angular js
.
Следующий код отлично работает на FireFox
, однако IE 11
выдает ошибку
Ожидается ':'
для строки return scope.valFunc({value});
Есть какие-нибудь идеи, как исправить это для IE
?Спасибо.
Директива:
crudApp.directive('customValidationFunction', function() {
return {
restrict: 'A',
require: 'ngModel',
scope: {
valFunc: '&customValidationFunction'
},
link: function(scope, element, attrs, controller) {
const normalizedFunc = function(modelValue, viewValue) {
const $value = modelValue || viewValue;
return scope.valFunc({$value});
};
controller.$validators.customValidationFunction = normalizedFunc;
}
};
});
Функция проверки :
//custom validation test
$scope.custValidationFunc = function($value) {
if (!$value) {
return true;
}
const lowVal = String($value).toLowerCase();
return lowVal.indexOf("arnold") === -1 && lowVal.indexOf("sylvester") === -1;
}
HTML:
<input type="text" class="form-control" id="i_position" name="i_position" aria-describedby="i_position_help" placeholder="Enter your Position" ng-model="position" custom-validation-function="custValidationFunc($value)">