Can I have replicate this switch statement behavior for Angular ng-switch directive anyway?
switch(variable){
case 'sample1':
case 'sample2':
//So common functionality for both 'sample1' and 'sample2' could be written here
break;
case 'sample3':
break;
}
In angular I tried using multiple ng-switch-when but it did not help.
I often come across scenarios where multiple cases options have share same implementations and I have to write redundant code for all those cases.
You feel there's a better practice I should follow then please share.
- I considered using ng-if as one option.
- I also tried transforming the case values ('sample1', 'sample2') to one common value (say 'sample_12_common' and hence write one match case in the snippet.
Thanks a lot.