<container-element [ngSwitch]="switch_expression">
<!-- the same view can be shown in more than one case -->
<some-element *ngSwitchCase="match_expression_1">...</some-element>
<some-element *ngSwitchCase="match_expression_2">...</some-element>
<some-other-element *ngSwitchCase="match_expression_3">...</some-other-element>
<!--default case when there are no matches -->
<some-element *ngSwitchDefault>...</some-element>
</container-element>
So in your case, you are trying to pass a condition to match_expression when the directive expects a value. You could pass a simple condition (e.g. number > 5 or number < 2) in the switch_expression, but since you have more than one condition this will not work.
You should go about it a different way, easiest would be with ngIf.
If you only want to apply styling conditionally you could also use ngStyle or ngClass
10
Max Tuzenko
On
I believe you are looking for ngStyle (conditional styling). You can use it like this:
ngSwitchis not the best way to do this, since thengSwitchexpression expects a match in thengSwitchCase.example from the documentation:
So in your case, you are trying to pass a condition to
match_expressionwhen the directive expects a value. You could pass a simple condition (e.g. number > 5 or number < 2) in theswitch_expression, but since you have more than one condition this will not work.You should go about it a different way, easiest would be with
ngIf. If you only want to apply styling conditionally you could also usengStyleorngClass