As ngIf or ngFor, ngSwitch is manipulating the DOM.
But, unless I miss something, it can only be called using [ng-switch] and not *ng-switch like we do for ngIf or ngFor.
<div [ng-switch]="value">
<div *ng-switch-when="'1'">is 1</div>
<div *ng-switch-when="'2'">is 2</div>
<div *ng-switch-default>is another value</div>
</div>
Maybe it would make more sense to have something like:
<div *ng-switch="value">
<div *ng-switch-when="'1'">is 1</div>
<div *ng-switch-when="'2'">is 2</div>
<div *ng-switch-default>is another value</div>
</div>
which would be closer to what we do for ngIf or ngFor:
<div *ng-if="test">..</div>
<li *ng-for="#user of users">{{user}}</li>
As
ngIforngFor,ngSwitchis manipulating the DOM.But, unless I miss something, it can only be called using
[ng-switch]and not*ng-switchlike we do forngIforngFor.Maybe it would make more sense to have something like:
which would be closer to what we do for
ngIforngFor: