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?

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.