What is the equivalent of ngShow and ngHide in Angular 2+?

后端 未结 18 2380
离开以前
离开以前 2020-11-22 14:46

I have a number of elements that I want to be visible under certain conditions.

In AngularJS I would write

stuff
18条回答
  •  没有蜡笔的小新
    2020-11-22 15:43

    There are two examples on Angular documents https://angular.io/guide/structural-directives#why-remove-rather-than-hide

    A directive could hide the unwanted paragraph instead by setting its display style to none.

    Expression sets display to "block". This paragraph is visible.

    Expression sets display to "none". This paragraph is hidden but still in the DOM.

    You can use [style.display]="'block'" to replace ngShow and [style.display]="'none'" to replace ngHide.

提交回复
热议问题