Skip to content

ngSwitch not using the * syntax ? #3306

@cexbrayat

Description

@cexbrayat

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions