-1
我想在我的應用程序中添加註銷。所以我打電話get /註銷web服務,我有一個url作爲響應。然後我使用這個URL將我的頁面重定向到返回的URL。window.location.href在打字稿中不起作用
這裏是我的代碼:
constructor(
$q: ng.IQService,
$location: ng.ILocationService,
$window: ng.IWindowService,
$http: ng.IHttpService
) {
this._$q = $q;
this._$location = $location;
this._$window = $window;
this.logout =() => {
return $http
.get(logoutUri, {})
.success((resp:any): void => {
window.location.href = resp;
});
};
}
在RESP,我得到了正確的URL,但我的網頁是不是重定向到特定的URL。
如果插入'的console.log(RESP)''設定window.location.href',什麼獲取寫入到開發者控制檯前,直接調用? –
它寫了正確的網址。我也嘗試了window.location.href ='http://www.google.com';它不起作用 –
然後我會通過。我還沒有深入瞭解AngularJS,但我認爲有一個專門用於重定向的功能。 –