Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angular2 forms validation - what does .ng-invalid:not(form)

Question

What does the :not(form) part of a CSS selector for angular2 form elements?

Context

The current version of the Angular2 tutorial about forms makes use of two-way data binding, change tracking and validation to add CSS classes to form elements.

Their example form looks like this enter image description here

And their example code to achive the red bar looks like this

.ng-invalid:not(form)  {
   border-left: 5px solid #a94442; /* red */
}
like image 250
Waog Avatar asked Mar 09 '23 05:03

Waog


1 Answers

Ah, I found it out myself!

the ng-invalid class is <form> elements, too.

So, :not(form) is added to prevent a red bar on the left side of the whole form.

like image 141
Waog Avatar answered Mar 19 '23 05:03

Waog