I have the following code and would like to optimise it:    $scope.languagePopover = angular.element(document.getElementById('language-popover'));    $scope.customPopover = angular.element(document.getElementById('custom-popover'));    var languageButton = angular.element(document.getElementById('language-button'));    var customButton = angular.element(document.getElementById('custom-button'));$scope.$watch(    function () {        return $scope.languagePopover[0].style.display;    },    function (newVal, oldVal) {        if ((newVal != oldVal) && (newVal === 'block')) {            $scope.languageButton.addClass('selected');        }        if ((newVal != oldVal) && (newVal === 'none')) {            if ($scope.languageButton.hasClass('selected')) { $scope.languageButton.removeClass('selected'); };        }    });$scope.$watch(     function () {        return $scope.customPopover[0].style.display;    },    function (newVal, oldVal) {        if ((newVal != oldVal) && (newVal === 'block')) {            $scope.customButton.addClass('selected');        }        if ((newVal != oldVal) && (newVal === 'none')) {            if ($scope.customButton.hasClass('selected')) { $scope.customButton.removeClass('selected'); };        }    });Maybe I don't understand the watchCollection function, but it doesn't seem to be what I need.  WatchGroup doesn't work in our angular version.
Angular $watch functions for two popovers
javascript;angular.js;scope