What is the difference between ng-if and ng-show/ng-hide

前端 未结 12 1563
执笔经年
执笔经年 2020-11-22 02:22

I\'m trying to understand the difference between ng-if and ng-show/ng-hide, but they look the same to me.

Is there a differenc

12条回答
  •  执笔经年
    2020-11-22 03:08

    ngIf makes a manipulation on the DOM by removing or recreating the element.

    Whereas ngShow applies a css rules to hide/show things.

    For most of the cases (not always), I would summarize this as, if you need a one time check to show/hide things, use ng-if, if you need to show/hide things based on the user actions on the screen (like checked a checkbox then show textbox, unchecked then hide textbox etc..), then use ng-show

提交回复
热议问题