0 votes
1 view
in Web Technology by (47.8k points)

I understand that ng-show and ng-hide affect the class set on an element and that ng-if controls whether an element is rendered as part of the DOM.

Are there guidelines on choosing ng-if over ng-show/ng-hide or vice-versa?

1 Answer

0 votes
by (107k points)
selected by
 
Best answer

  • Elements that are not in the DOM have less performance impact and your web app might appear to be faster when using ng-if compared to ng-show/ng-hide. The difference is negligible. Animations are possible when using both ng-show/ng-hide and ng-if, with examples for both in the Angular documentation.

  • The ng-if will remove elements from DOM where as the ng-show/ng-hide does not remove the elements from the DOM.

  • The ng-if creates a child scope while ng-show/ng-hide does not.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Sep 3, 2019 in Web Technology by Sammy (47.8k points)
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...