このモジュールをアプリに追加しました:https ://github.com/witoldsz/angular-http-auth/blob/gh-pages/lib/http-auth-interceptor.js
401応答でメッセージをブロードキャストするので、とても便利です。$routeProviderに$rootscope。$broadcastをリッスンさせる方法がわかりません。401sのサインインページにリダイレクトしたいのですが。
私の$routeProvideは次のようになります。
var app = angular.module('demoApp', ['http-auth-interceptor','tastypieModule'])
.config(function($routeProvider) { $routeProvider.
when('/', {controller:HomeCrtl, templateUrl:'partials/home.html'}).
when('/sign-in', {controller:SiginInCtrl, templateUrl:'partials/sign-in.html'}).
otherwise({redirectTo:'/'});
})