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

后端 未结 6 1097
名媛妹妹
名媛妹妹 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

    There is actually another difference between them when you try to manipulate elements within the structures that are wrapped within a section:

    ngIf will cause an undefined error in your code if you try reference an element within that section when is false.

    [hidden] will not cause an undefined error in your code if you try to reference an element within the section, when that section is hidden.

    So [hidden] is better used when we want to operate on elements within the wrapped section.

提交回复
热议问题