Sarah cartenz Sarah cartenz - 1 year ago 79
CSS Question

what is the difference between [hidden] in the div and using ng-show?

I was going through the Angular 2 documentation and found the following:

<div [hidden]="name.valid || name.pristine"
class="alert alert-danger">

There is no explanation on the
part. Is it a HTML property, CSS or Angular? Why isn't
used instead?

Answer Source

ng-show is a history of angular1. Before there was no hidden property (standard HTML, it is available starting from ie11) also all standard properties were covered by some similar angular directives which were doing the stuff.

This was a problem because it forced angular programmers to learn lots of directives.

Angular2 idea was to remove all unnecessary directives, and ng-show was one of them. Instead, angular2 introduced a property binding [hidden] which does the same job.

So the answer is: this is standard HTML property utilized by the angular2 property binding.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download