AIA.controller("AnatTestController", ["$scope", "$rootScope", "pages", "$log", "$location", function ($scope, $rootScope, pages, log, $location) { $scope.showTabButton = false; $scope.IsVisible = function () { $scope.scroll(); } $scope.scroll = function () { // $window.scrollTo(0, 0); $("html,body").scrollTop(0); //alert("scroll"); } $scope.$on('$viewContentLoaded', function (event) { // code that will be executed ... // every time this view is loaded //get current path var currentURL = $location.path(); var selectedModuleName = ''; //set module title angular.forEach($rootScope.userModules, function (value, key) { if (value.slug === currentURL.replace('/', '')) { selectedModuleName = value.name; } $rootScope.currentActiveModuleTitle = selectedModuleName; }) }) // $rootScope.currentActiveModuleTitle = pages[7].name; }] );