Angular controller to handle showing or hiding multiple widgets 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);
You could change your ng-show to use a function:

ng-show="isShown('widgetX')" ng-click="toggleWidget('widgetX')"


And then in your controller:

var widgets = {
    widgetA: {
        shown: true
    },
    widgetB: {
        shown: true
    },
    ...
};

$scope.isShown = function(widgetID) {
    return widgets[widgetID].shown;
}

$scope.toggleWidget = function(widgetID) {
    widgets[widgetID].shown = !widgets[widgetID].shown;
}