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

后端 未结 18 2216
离开以前
离开以前 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:38

    Best way to deal with this issue using ngIf Because this well prevent getting that element render in front-end,

    If you use [hidden]="true" or style hide [style.display] it will only hide element in front end and someone can change the value and visible it easily, In my opinion best way to hide element is ngIf

    stuff

    and also If you have multiple element (need to implement else also) you can Use option

    
    
         
    loadMenu
    loadAdmin

    sample ng-template code

提交回复
热议问题