0

I'm trying to make a simple input that validates only by matching some data in scope, literally:

<ng-form name="fooForm">
  <input required
         pattern="/{{foo}}/"
         ng-model="dummy"
         name="shouldBeFoo" />
  <button ng-class="{disabled: fooForm.shouldBeFoo.$invalid}">
    Run Foo
  </button>
</ng-form>

However, running this code shows that the $invalid attribute doesn't account for the interpolated pattern. Is there a programmatic way of setting the input's validation to equal foo, precisely? Maybe some function predicate?

Athan Clark
  • 3,886
  • 2
  • 21
  • 39

1 Answers1

0

See ng-pattern to specify a pattern using an expression: https://docs.angularjs.org/api/ng/directive/input

Zach Snow
  • 1,014
  • 8
  • 16