meteor-angular2.0-socially
meteor-angular2.0-socially copied to clipboard
Chapter 16: NgIf - Hidden comparison
16. Conditional Template, you wrote :
While
hiddenshows and hides a DOM element that is already rendered,ngIfadds or removes an element from the DOM, making it both heavier and slower.
Angular2 Doc Template Syntax, they wrote :
When we hide the element subtree, it remains in the DOM. Components in the subtree are preserved, along with their state. Angular may continue to check for changes even to invisible properties. The subtree may tie up substantial memory and computing resources.
When NgIf is false, Angular physically removes the element subtree from the DOM. It destroys components in the subtree, along with their state, potentially freeing up substantial resources and resulting in better performance for the user.
The show/hide technique is probably fine for small element trees. We should be wary when hiding large trees; NgIf may be the safer choice. Always measure before leaping to conclusions.
@nebiljabari can you PR to make the docs reflect the Angular text?