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
ng-if if false will remove elements from DOM. This means that all your events, directives attached to those elements will be lost. For example, ng-click to one of child elements, when ng-if evaluates to false, that element will be removed from DOM and again when it is true it is recreated.
ng-show/ng-hide does not remove the elements from DOM. It uses CSS styles (.ng-hide) to hide/show elements .This way your events, directives that were attached to children will not be lost.
ng-if creates a child scope while ng-show/ng-hide does not.