ngSwitchWhen fails when used with custom directives without a separate closing tag
This works ok:
<div ng-switch="activePartial">
<page-details ng-switch-when="Page" page-detail="pageDetail"></page-details>
<page-template-validation ng-switch-when="PageTemplateValidation" page-detail="pageDetail"></page-template-validation>
</div>
this works only for the first When statement:
<div ng-switch="activePartial">
<page-details ng-switch-when="Page" page-detail="pageDetail"/>
<page-template-validation ng-switch-when="PageTemplateValidation" page-detail="pageDetail"/>
</div>
However, using for example <img /> instead of a custom directive works ok.
I may be wrong on this, but I believe that custom html elements like <page-details> require a closing tag. Not having one can cause the browser to render elements incorrectly, and even close the parent element altogether. I suspect that the reason the second when in your example does not work is because HTML is closing before <page-template-validation> happens.
Tags like <img /> work because they are special parts of HTML and it knows how to render them correctly. I do not think this has anything to do with the ng-switch directive. I had a similar issue when I built a few custom input elements. <ui-input ... /> worked but nothing in the rest of the parent container would work. I changed it to <ui-input ...></ui-input> everything else began to work.
Hope this helps.
This is one of the parts of the standard that is fuzzy, in a strict sense only elements of content type empty can be self closing and there is no definition of the content type of HTMLUnknownElement. Now, given that all browsers do not detect self closing tags on unknown element types, the de-facto standard is that the content type of HTMLUnknownElement is not empty and this implies that self closing tags are not detected as such
@ochrons - this is down to how browsers parse the HTML. As @studiothree10 and @lgalfaso point out, you mostly can't have self-closing custom html tags. AngularJS only gets access to the DOM elements after they have been parsed into the DOM by the browser so nothing it can do about "invalid" HTML.