rt-multiple-switch
v1.1.0
Published
The module provides directives similar to `ngSwitch` but for multiple cases simultaneously. It is supposed to be used in highly dynamic applications based on configs.
Downloads
16
Readme
About
RT Multiple Switch
The module provides directives similar to ngSwitch
but for multiple cases simultaneously.
It is supposed to be used in highly dynamic applications based on configs.
Install
npm i rt-multiple-switch
yarn add rt-multiple-switch
Usage
Import RtMultipleSwitchDirective
& RtMultipleSwitchCaseDirective
into your module or standalone component.
import {RtMultipleSwitchDirective, RtMultipleSwitchCaseDirective} from './rt-multiple-switch/rt-multiple-switch.ts';
...
imports:
...
RtMultipleSwitchDirective,
RtMultipleSwitchCaseDirective,
...
...
Api
Directives:
RtMultipleSwitchDirective
- Same usage asngSwitch
, but takes array of the strings instead of single one.RtMultipleSwitchCaseDirective
- Same usage asngSwitchCase
. Takes string as an input. Displays content if input string is included intoRtMultipleSwitchDirective
input array.
Example
Directive usage:
<ng-container [rtMultipleSwitch]="['Case_1', 'Case_3', 'Case_3', 'Case_2', 'Case_7']">
<ng-container *rtMultipleSwitchCase="'Case_1'">Case 1 Displayed.</ng-container>
<ng-container *rtMultipleSwitchCase="'Case_2'">Case 2 Displayed.</ng-container>
<ng-container *rtMultipleSwitchCase="'Case_3'">Case 3 Displayed.</ng-container>
<ng-container *rtMultipleSwitchCase="'Case_4'">Case 4 Displayed.</ng-container>
<ng-container *rtMultipleSwitchCase="'Case_5'">Case 5 Displayed.</ng-container>
<ng-container *rtMultipleSwitchCase="'Case_6'">Case 6 Displayed.</ng-container>
<ng-container *rtMultipleSwitchCase="'Case_7'">Case 7 Displayed.</ng-container>
<ng-container *rtMultipleSwitchCase="'Case_8'">Case 8 Displayed.</ng-container>
</ng-container>
Result:
Case 1 Displayed.
Case 3 Displayed.
Case 3 Displayed.
Case 2 Displayed.
Case 7 Displayed.