const dataSource = "data.json"; // JSON input file angular .module("main", []) .controller("ctrl", ($scope, $http, $rootScope, $location) => { $scope.showTable = false; $scope.sPresentation = undefined; $scope.strCheck = str => { return str == "" || str == undefined || str == null ? "N/A" : str; }; $http.get(dataSource).then(response => { $scope.data = response.data; $rootScope.title = $scope.strCheck($scope.data.title); $scope.$watch( () => location.hash, value => { if (value == "" || value == undefined || value == null || value == "#!/") { $scope.showTable = false; $scope.sPresentation = undefined; $rootScope.title = $scope.strCheck( $scope.data.title ); } else { $scope.displayTable($location.hash()); } } ); }); $scope.displayTable = path => { $http.get(path).then(response => { $location.hash(path); $scope.sPresentation = response.data; $scope.showTable = true; $rootScope.title = $scope.strCheck( $scope.sPresentation.title ); }); }; });