I have implemented a single page application with angular js. Here is part of my application config:
var app = angular.module("myApp", ['angular-loading-bar', 'ngRoute'])
.config(['cfpLoadingBarProvider', function(cfpLoadingBarProvider) {
cfpLoadingBarProvider.latencyThreshold = 1;
}]);
app.config(['$routeProvider', '$locationProvider',
function($routeProvider, $locationProvider, $compile) {
$routeProvider.
when('/employee/master', {
templateUrl: '/shop/employee/master',
controller: 'EmployeeController'
}).
.
.
.
}]);
And the controller:
app.controller('EmployeeController', function($scope, $templateCache)
{
//some stuff
});
The /shop/employee/master url is a url of my server controller(not angular controller) and returns me an html content. But sometimes that server action may redirect to some other actions for some reasons(for example user's session time out). I need to detect http status 302(redirection) when angular get the template, But I don't know how can I capture angular GET request for template.
$httpinterceptors. It is better to cache the templates on load using the$templateCacheservice. See here and here for how to do this.