What is the difference between *ngIf and [hidden]?

后端 未结 6 1099
名媛妹妹
名媛妹妹 2020-11-30 06:14

Say I check it against and expression, then aren\'t these two same ?

{{val}}
6条回答
  •  我在风中等你
    2020-11-30 07:11

    ngIf is a structural directive, it creates/destroys content inside the DOM. The second statement just hides/shows the content with css, i.e. adding/removing display:none to the element's style.

    What are structural directives?

    Structural directives are responsible for HTML layout. They shape or reshape the DOM's structure, typically by adding, removing, or manipulating elements.


    In the first case if expression is false then div and it's content won't be created. In the second case div and content are always created but they are not visible if the expression is false.

提交回复
热议问题