我使用的是Angular 11。不知怎么的,我不能让这个div消失:我的简单HTML
:
<div ng-hide="true">Test</div>
结果->文本测试仍然显示在我的页面上。
在Angular2+中没有ng-
格式的指令。此格式仅适用于angular.js
。但你知道Angular2+中几乎有相同的指令。
对于您的问题,有一些方法可以实现ng-hide
:的相同行为
第一个是:[hidden]=true
:
<div [hidden]="true">…content..</div>
第二个是:*ngIf
<div *ngIf=”bolShow”>…content…</div>
第三个是像这样的样式绑定:[style.visibility]
<div [style.visibility]="bolShow ? 'visible' : 'hidden'">…content…</div>
ng-hide
和ng-show
不存在于Angular 2+中,仅存在于AngularJS中。我正在使用
<div [hidden]="true">Text</div>
现在。
https://www.telerik.com/blogs/what-is-the-equivalent-of-ng-show-and-ng-hide-in-angular