var arr = window.location.href.split("/"); if (arr[3].indexOf('app') == 0) baseUrl = ''; else baseUrl = '/' + arr[3]; angular.module('CarbonFootprint') .config(function ($routeProvider) { $routeProvider.when('/Report/Index', { templateUrl: baseUrl+'/Partials/Report-Index', controller: 'ReportController' }); }) .controller('ReportController', ['$scope', '$http', '$timeout', function ($scope, $http, $timeout) { $scope.searchText = ""; // set $scope.baseUrl var baseUrl = $scope.baseUrl; if (typeof (baseUrl) === 'undefined' || baseUrl == null) { var arr = window.location.href.split("/"); if (arr[3].indexOf('app') == 0) baseUrl = ''; else baseUrl = '/' + arr[3]; $scope.baseUrl = baseUrl; } $scope.downNameRewrite = function (name) { if (typeof name != 'undefined' && name != null) { return "Download"; } } $http.get($scope.baseUrl+'/api/LCA/GetMyReports') .success(function (data, status, headers, config) { $scope.reportList = data; }); } ]);