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

前端 未结 12 1548
执笔经年
执笔经年 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:10

    ng-show and ng-hide work in opposite way. But the difference between ng-hide or ng-show with ng-if is,if we use ng-if then element will created in the dom but with ng-hide/ng-show element will be hidden completely.

    ng-show=true/ng-hide=false:
    Element will be displayed
    
    ng-show=false/ng-hide=true:
    element will be hidden
    
    ng-if =true
    element will be created
    
    ng-if= false
    element will be created in the dom. 
    

提交回复
热议问题