Last active
August 29, 2015 14:25
-
-
Save himetani/d469ce9c4de6111a03ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('myApp', ['ui.bootstrap', 'ui.router']) | |
.config(function($locationProvider, $stateProvider, $urlRouterProvider, $httpProvider){ | |
$locationProvider.html5Mode({ | |
enabled: true, | |
requireBase: false | |
}) | |
$urlRouterProvider.otherwise('/login') | |
$httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest' | |
$httpProvider.interceptors.push(function($q, $location) { | |
return { | |
response: function(response) { | |
return response | |
}, | |
responseError: function(response) { | |
if (response.status === 401) $location.url('/login') | |
return $q.reject(response); | |
} | |
}; | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment