I'm attempting to add ng-pattern to specific inputs on specific forms using the following directive. It's adding the ng-pattern, but the validation isn't working. However, the validation works fine whenever I add the ng-pattern manually to the inputs. My only assumption as to why this isn't working is that angular isn't recognizing the ng-pattern being added to the input fields? If that's the case, how can this be resolved? Sorry, I'm kind of an Angular noob. Here's my directive:
.directive('billValidation', [() => {
return {
restrict: 'A',
link:(scope, element, attrs) => {
$(element).find('.validate-bill-input').each(function() {
$(this).attr('ng-Pattern', '/^[a-zA-Z0-9 ]+$/');
});
}
}
}])