私が達成しようとしているのは、セッションがどのページからタイムアウトした場合、ユーザーをログインページにリダイレクトしていて何らかのエラーを表示したいのです。今はリダイレクトできますが、エラー部分は機能していません。角度:エラーページと一緒にログインページにリダイレクト
これは私のhttpInterceptor
@app.service 'httpInterceptor', [
'$window',
'AuthenticationService'
($window, AuthenticationService) ->
{
responseError: (res) ->
if res.status == 403
AuthenticationService.error = true;
$window.location.href = '/'
res
}
]
と私は
@app.service 'AuthenticationService', ->
@error = false
return
AuthenticationService.error
このサービスを利用しようとしていますが、私はまだ、この値はfalseとして取得していますログインコントローラです。
EDIT JSコード
this.app.service('httpInterceptor', [
'$window',
'AuthenticationService',
($window, AuthenticationService) =>
({
responseError(res) {
if (res.status === 403) {
AuthenticationService.error = true;
$window.location.href = '/';
}
return res;
}
})
]);
サービス
this.app.service('AuthenticationService', function() {
this.error = false;
});
これはどの言語ですか? coffeescript?角で:)? – PierreDuc
はいそれはcoffeescriptです – Saad
@PierreDuc私はJSコード – Saad