Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Web Technology by (47.6k 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?

closed

1 Answer

0 votes
by (106k 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
asked Sep 3, 2019 in Web Technology by Sammy (47.6k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...