1
When I begin to abstract in various functions my systems, this doubt almost always appears to me. I have the value "local" in the variable sPrg, and I need to concatenate with "Ctrl.save" to call the function.
How can I reduce this so I don’t need to use the switch
?
ctrl.gravar = function (sPrg) {
switch(sPrg){
case "local":
localCtrl.gravar();
break;
case "banco":
bancoCtrl.gravar();
break;
case "cartao":
cartaoCtrl.gravar();
break;
case "saldo":
saldoCtrl.gravar();
break;
}
};