Using a form input directive with ng-pattern. It works (i.e. error is displayed) when the ID on the directive is a string, but fails (i.e. error never displayed) when the ID is an expression. Pseudo code:
works
<form name="myForm" role="form" ng-submit="customer.submit()">
<form-input id="foo" ng-pattern="/^[0-9]+$/"></form-input>
</form>
<span ng-show="myForm.foo.$error.pattern" class="ng-hide">Not valid number!</span>
doesn't work (myVar = "foo")
<form name="myForm" role="form" ng-submit="customer.submit()">
<form-input id="{{myVar}}" ng-pattern="/^[0-9]+$/"></form-input>
</form>
<span ng-show="myForm.foo.$error.pattern" class="ng-hide">Not valid number!</span>
Chrome Inspected HTML (exactly same for working/not working)
<input type="text" id="foo" name="foo" ng-pattern="/^[0-9]+$/" class="ng-valid ng-valid-pattern">
<span ng-show="myForm.foo.$error.pattern" class="ng-hide">Not valid number!</span>
Assume this is because the expression ID is undefined when everything is wired up, but no idea how to fix. Thanks in advance!