meteor-angular2.0-socially icon indicating copy to clipboard operation
meteor-angular2.0-socially copied to clipboard

Chapter 16: NgIf - Hidden comparison

Open nebiljabari opened this issue 8 years ago • 2 comments

16. Conditional Template, you wrote :

While hidden shows and hides a DOM element that is already rendered, ngIf adds 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 avatar Nov 29 '16 22:11 nebiljabari

@nebiljabari can you PR to make the docs reflect the Angular text?

Urigo avatar Dec 12 '16 20:12 Urigo