0

Simple question:

Why is it that the summary class can directly be appended to the <span> element but not the ng-classes to the <form> tag?

Is it because the ng-classes are later generated during runtime? What are the guidelines?

CSS:

enter image description here

HTML:

enter image description here

1 Answer 1

2

That is not how you use ng-class. Instead do this:

<span class="summary" ng-class="{ 'ng-valid': myForm.$valid, 'ng-invalid': !myForm.$valid }">...</span>

If you want to do it the way you have it do it like this:

<span class="summary {{ myForm.$valid ? 'ng-valid' : 'ng-invalid' }}">...</span>

Next time you need help on stackoverflow, please paste the code instead of images. Would make it a lot easier.

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

1 Comment

Isn't this a matter of taste? According to my book, this is how its supposed to be done - speaking for myself, I visually prefer the syntax from the book (in case there aren't any other benefits). Anyway, the orginal question was related to the extra space between the form ng-invalid.ng-dirty compared to span.summary.ng-invalid css selector part.

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.