This article is a mirror article of machine translation, please click here to jump to the original article.

View: 9089|Reply: 0

[Angular] Angular element ngif hidden visibility is displayed and hidden

[Copy link]
Posted on 4/20/2022 2:19:56 PM | | |
If you want to hide a DOM element, you can use ng-show, ng-hide, or ng-if in AngularJS.

Review:


Use *ngIf

He will remove the DOM element directly.

Use [hidden]

In Angular, the hidden attribute actually uses the HTML-native hidden attribute to hide the element, which actually adds the display: none style to the element and does not remove the DOM element.

Use visibility

display:none;不占位隐藏,隐藏元素及元素内的所有内容,并且该元素的位置、宽高等其他属性值一并“消失”;

visibility:hidden;Placeholder hidden, hides the element and all the contents within it, but the position, width and height of the element are still there. Default: visible.

Code:







Previous:Prevent CSRF attacks on the cookie's SameSite property
Next:SQL Server migrates database files to another disk
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com