6

what is the difference between ngSwitch and ngInclude?

I really need to understand the difference, so I can continue on my project.

Does the ngSwitch hides only the dom elements?

David B.
  • 87
  • 7

1 Answers1

5

You may find the v1.1.4 documentation more helpful (just ignore the stuff about animations if you are not using 1.1.4): ngSwitch

ngSwitch conditionally adds/removes DOM elements (ng-show/hide alters CSS).

ngInclude can fetch partials/external HTML fragments.

Both create new child scopes that prototypically inherit from their parent scopes. (A new child scope is created for each ng-switch-when/default.)

You can use ngInclude with ngSwitch: https://stackoverflow.com/a/12584774/215945

Use ngInclude when you want to (or can) reuse HTML fragments, such as client UI (https://stackoverflow.com/a/13005658/215945).

Community
  • 1
  • 1
Mark Rajcok
  • 362,217
  • 114
  • 495
  • 492
  • But the problem using NgInclude on my page is, I have 1000 elements on dataTables, and when I use ngInclude it freezes a litle while all elements are loading. I need something to hide/show – David B. May 14 '13 at 15:24
  • I have 5 different html pages, thats why I use ngInclude currently but its somehow not a good solution for my case. ngInclude makes the dataTable reinitialize, so it freezes everytime I switch between the pages. – David B. May 14 '13 at 15:30