I have 7 variables controlling 7 widgets showing or hiding from the frontend. I want to put them together and control all of them using one function. Here is what I have. However, I feel like even though this way works, the code is really ugly and should have space for improvements.
$scope.showWidget = function(showA, showB, showC, showD, showE, showF, showG) {
if (showA !== null) {
$scope.showshowA = showA;
}
if (showB !== null) {
$scope.showshowB = showB;
}
if (showC !== null) {
$scope.showshowC = showC;
}
if (showD !== null) {
$scope.showD = showD;
}
if (showE !== null) {
$scope.showshowE = showE;
}
if (showF !== null) {
$scope.showshowF = showF;
}
if (showG !== null) {
$scope.showG = showG;
}
}
E.G. I will use the following code snippet for controlling showG variable on the fly.
$scope.showWidget(null, null, null, null, null, null, true);