我有一個HTML頁面的鏈接如下:同步使用跨頁變量angularJs
<div ng-if="!adminCtrl.valid">
<div><a target="_blank" ng-href="https://api.instagram.com/oauth/authorize/?client_id=xxx&redirect_uri=http://localhost:8888/igSuccess.html&response_type=token">Authorize to Instagram</a><br/></div>
</div>
這一切都成功重定向頁面,代碼是
<div ng-controller="AdminController">
<h2>You can close this tab/window</h2>
</div>
的控制是相同的這兩個頁面如下:
app.controller('AdminController', ['$scope','$routeParams','$location', function($scope,$routeParams,$location){
var actrl = this;
actrl.valid = false;
var token = $location.absUrl();
if(token.indexOf('access_token') > -1){
console.log('found token so will do special');
actrl.valid = true;
$scope.$apply();
}
}}
我期待鏈接消失一旦新頁面打開,因爲我更新確定有效的變量值。
我知道這個漏洞似乎是跨頁面溝通。那麼如何處理呢?
你得到了示蹤項目符號 - 「console.log('found token')' - 來觸發,更正?對不起,我必須問... –
是的,但它出現在重定向頁面的控制檯日誌中 – Vik