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
@Gajus Kuizinas and @CodeHater are correct. Here i am just giving an example. While we are working with ng-if, if the assigned value is false then the whole html elements will be removed from DOM. and if assigned value is true, then the html elements will be visible on the DOM. And the scope will be different compared to the parent scope. But in case of ng-show, it wil just show and hide the elements based on the assigned value. But it always stays in the DOM. Only the visibility changes as per the assigned value.
http://plnkr.co/edit/3G0V9ivUzzc8kpLb1OQn?p=preview
Hope this example will help you in understanding the scopes. Try giving false values to ng-show and ng-if and check the DOM in console. Try entering the values in the input boxes and observe the difference.
ng-show=true ::
ng-if=true ::
{{data}}