1

I have some sets of patterns in my controller. I am trying to set this pattern dynamically for ng-pattern using ng-repeat.

Pattern example :

$scope.codePattern = (function () {
  var regexp = /^([a-zA-Z0-9_]+){2,}$/;
  return {
    test(value) {
      return regexp.test(value);
    },
  };
})();

This pattern name is stored in DB and is assigned to ng-pattern in ng-repeat. But somehow this is not working. However, when I hard-code it works perfectly.

Lioness100
  • 8,260
  • 6
  • 18
  • 49

0 Answers0