0

I'm working on an AngularJS front end for my ASP.NET MVC project. I want to display the contents of /app/views/home.html when the application starts. However, when I debug the app, the above error is loaded despite the template being referenced in app.js as follows:

var app = angular.module("app", ['ngResource','ngRoute', 
'LocalStorageModule', 'ui.bootstrap']);

app.config(function ($routeProvider) {
$routeProvider.when("/", {
    controller: "HomeController",
    templateUrl: "/app/views/home.html"
});

$routeProvider.when("/application", {
    controller: "ApplicationController",
    controllerAs: "vm",
    templateUrl: "/app/application/application.html"
});

$routeProvider.when("/login", {
    controller: "LoginController",
    controllerAs: "ctrl",
    templateUrl: "/app/views/login.html"
})

$routeProvider.otherwise("/")
});

I've installed the UI Bootstrap NuGet package and added the script files to BundleConfig as well. I found this link which mentions that an interceptor was in use and when commented out remedied their situation. I too have an interceptor and did the same which fixed the immediate issue. My interceptor service is as follows:

app.factory("authInterceptorService", ['$q', '$injector', '$location', 
'localStorageService', function ($q,$injector, $location, 
localStorageService) {
var authInterceptorServiceFactory = {};
var _request = function (config) {
    config.headers = config.headers || {};
    var authData = localStorageService.get('authorizationData');

    if (authData) {
        config.headers.Authorization = 'Bearer ' + authData.token;
    }
    return config;
}

var _responseError = function (rejection) {
    if (rejection.status === 401) {
        var authService = $injector.get('authService');

        if (authData) {
            if (authData.useRefreshTokens) {
                $location.path('/refresh');
                return $q.reject(rejection);
            }
        }
        authService.logOut();
        $location.path('/login');
    }
    return $q.reject(rejection);
}

authInterceptorServiceFactory.request = _request;
authInterceptorServiceFactory.response = _responseError;

return authInterceptorServiceFactory;
}])

What other changes are needed to ensure my views are properly displayed?

Community
  • 1
  • 1
SidC
  • 3,175
  • 14
  • 70
  • 132

0 Answers0