I am trying to ensure that the last letter of a field must end with a specific letter in angularjs text field. I have created a function that handles the pattern validation as shown
$scope.validatePattern = function () {
var typeSelected = $scope.sports_type;
if (typeSelected == 'Sports') { //the user selected sports from the above model
$scope.pointPattern = "^[\s\w]+[^(ess|essence)]$";
}
}
I am using the pattern in below fields.
<label>Sports Option</label>
<input ng-model="option" ng-minlength="3" formcontrol name="option" type="text" ng-pattern="{{pointPattern}}" required>
<p ng-show="frmValidation.option.$invalid" class="input-error-message">Option is required</p>
<p ng-show="frmValidation.option.$error.pattern">Not valid! Must end with ess or essence</p>
why is the ng-pattern not validating that the letter must end with ess or essence