0

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.

hamed
  • 7,939
  • 15
  • 60
  • 114
  • Possible duplicate of [How do I get the HTTP response status code in AngularJS 1.2](http://stackoverflow.com/questions/18729556/how-do-i-get-the-http-response-status-code-in-angularjs-1-2) – Khalid Hussain Feb 22 '16 at 08:32
  • As far as I'm aware this isn't really possible, unless you do some awkward logic with [`$http` interceptors](https://docs.angularjs.org/api/ng/service/$http#interceptors). It is better to cache the templates on load using the [`$templateCache`](https://docs.angularjs.org/api/ng/service/$templateCache) service. See [here](http://stackoverflow.com/questions/12346690/is-there-a-way-to-make-angularjs-load-partials-in-the-beginning-and-not-at-when) and [here](http://stackoverflow.com/questions/18714690/is-there-a-way-to-preload-templates-when-using-angularjs-routing) for how to do this. – Rhumborl Feb 22 '16 at 09:53

0 Answers0