Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the difference between ngSwitch and ngInclude?

Tags:

angularjs

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?

like image 505
David B. Avatar asked May 14 '13 15:05

David B.


1 Answers

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).

like image 122
Mark Rajcok Avatar answered Oct 12 '22 07:10

Mark Rajcok