I\'m terrible with regular expressions but I was wondering if it was possible to use ng-pattern with a variable
For example,
ng-pattern=\"/^{{valid
ng-pattern expects a regex expression.
From Angular's documentation about ng-pattern:
Sets pattern validation error key if the value does not match the
RegExppattern expression. Expected value is/regexp/for inline patterns orregexpfor patterns defined as scope expressions.
In other words, you could create a RegExp in the controller:
$scope.pattern = new RegExp(patternFromServer);
and use it:
<input ng-model="foo" ng-pattern="pattern">