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

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

    I find myself in the same situation with the difference than in my case the element was a flex container.If is not your case an easy work around could be

    [style.display]="!isLoading ? 'block' : 'none'"
    

    in my case due to the fact that a lot of browsers that we support still need the vendor prefix to avoid problems i went for another easy solution

    [class.is-loading]="isLoading"
    

    where then the CSS is simple as

    &.is-loading { display: none } 
    

    to leave then the displayed state handled by the default class.

提交回复
热议问题