question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ngSwitchCase directive does not work with multiple values

See original GitHub issue

I’m submitting a … (check one with “x”)

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Using multiple values as an expression in the ngSwitchCase directive only works with the first value and does not give any errors.

Expected behavior

Show view when ngSwitch matches second value of the ngSwitchCase expression.

Minimal reproduction of the problem with instructions

<div [ngSwitch]="status">
  <div *ngSwitchCase="statusEnum.Loaded || statusEnum.Selected">
    <p>I should show up when status is either Loaded or Selected!
  </div>
</div>

What is the motivation / use case for changing the behavior?

Make everyone happy who need to use multiple values.

Please tell us about your environment:

Windows 10

  • Angular version: 2.0.1

  • Browser: [all]

  • Language: [all]

  • Node (for AoT issues): node --version =

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

11reactions
itsnotvalidcommented, Mar 12, 2017

Needa quote string is pretty dumb…

8reactions
wayearncommented, Feb 23, 2017
Read more comments on GitHub >

github_iconTop Results From Across the Web

Two switch case values in angular - Stack Overflow
Option 1 is using the directive *ngSwitchDefault , but this will only work if all your multiple cases are FORM 1: <div [ngSwitch]="data.type">...
Read more >
NgSwitchCase - Angular
When the expressions match, the given NgSwitchCase template is rendered. If multiple match expressions match the switch expression value, all of them are...
Read more >
Angular 14 NgSwitch Directive Tutorial with Examples
It gets the switch value based on the matched statement among multiple possibilities. ngSwitchCase, The ngSwitchCase statement is declared ...
Read more >
ngSwitch, ngSwitchcase, ngSwitchDefault Angular Example
The ngSwitch is an Angular directive, which allows us to display one or more DOM elements based on some pre-defined condition. The following...
Read more >
NgIf & NgSwitch • Angular - codecraft.tv
We can't have two structural directives, directives starting with a *, attached to the same element. The below code would not work: HTML....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found