使用 CLI 时 ng-show Angularjs 不工作

ng-show Angularjs not working when using CLI

我刚刚使用 ng new app 构建了 Angular 应用程序。我想有条件地隐藏一些元素。我试图使用 ng-show 来做到这一点。但它不起作用。

    <span ng-show="false">Angular App</span>

无论我将什么作为参数放入 ng-show,该元素始终显示。我需要导入任何东西还是我在某些语法上出错了?

感谢@Moshezauros 和@Avinash Sharma 提出的宝贵意见。 *ngIf 效果不错。 *ngShowng-show 不起作用。

现在,ng-showng-if 中非常重要的区别是 ng-show 只是切换可见性,而 ng-if 会从 DOM 中删除元素。这会影响各种用例的性能。

因此,要在 AngularjsAngular 的现代版本中产生等同于 ng-show 的效果,您应该使用 [hidden] = condition.

使用

<span [hidden]="true">Angular App</span>