2

I have the following code:

  <div class="box" *ngSwitchCase="'financing'">
  <div class="box" *ngSwitchCase="'procurement'">
  <div class="box" *ngSwitchCase="'operations'">

I am using the ngSwitchCase to switch between the divs depending on what the user selects. However, I want to add one last switch case that allows the user to view all three divs at one, as follows:

 <div class="box" *ngSwitchCase="'financing'">
 <div class="box" *ngSwitchCase="'procurement'">
 <div class="box" *ngSwitchCase="'operations'">
  <div class="box" *ngSwitchCase="'summary'">

The way I have it now is that the summary part contains all the of the contents of the upper 3 divs.

How can I achieve the same case but without repeating my code?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
abedzantout
  • 802
  • 4
  • 15
  • 28
  • 2
    You could use `ngIf` instead if you don't actually want the mutually exclusive behaviour of `ngSwitch`. – jonrsharpe Dec 22 '16 at 21:57
  • @jonrsharpe wouldn't I still in that case still need to copy all of the contents into the summary div? – abedzantout Dec 22 '16 at 22:01
  • No, you show each div if either only it should be shown or all should be shown. `*ngIf="whatever == 'summary' || whatever == 'operations'"`. – jonrsharpe Dec 22 '16 at 22:03

0 Answers0