Samantha J T Star
Samantha J T Star

Reputation: 32808

How can I hide a span if an input field is valid with AngularJS?

I can do this:

 <span ng-show="form.size.$error.integer">Problem</span>

but I have a number of different possible errors so is there a way I can hide the span if the field is valid?

Upvotes: 0

Views: 66

Answers (2)

Adam Łepkowski
Adam Łepkowski

Reputation: 2078

You can use $valid property, such us:

   <span ng-hide="form.size.$valid">Problem</span>

Upvotes: 1

You can use the $valid property of the form.

<span ng-show="form.size.$error.integer && ! form.size.$valid">Problem</span>

But Im not sure why you need this. If there is no error, form.size.$error.integer should be false and it should be hidden anyways.

Upvotes: 1

Related Questions