Reputation: 12646
When I use a RegEx as a string to only allow digits, it works fine, like so:
<input ng-model="txtInputValueOne"
ng-pattern = "/^\d+$/">
When I use it with a variable, it does NOT work correctly ("working correctly" = allowing only digits into the input model result):
<input ng-model="txtInputValueTwo"
ng-pattern = "intPattern">
$scope.regExString = "\d+"
$scope.intPattern = new RegExp($scope.regExString);
What's the problem? PLUNK
Upvotes: 0
Views: 76