目前特定页面上的后退按钮覆盖特定的Tab-SubTab(A)我将它应用于 - 在SubTabA上,后退按钮将我带回TabA,但$ scope。$ on('$毁灭......)似乎没有奏效。因为如果从Tab-SubTab(A)和我直接导航到另一个Tab-SubTab(C)页面 - Tab-SubTab(C)上的后退按钮将我直接带回TabA而不是返回到TabC。
此外,如果我回到TabC - 它会直接进入Tab-SubTabC(因为那是它最后一次停止的地方),我永远无法回到TabC。
以下是我所在的特定页面/标签的控制器:
<?php
function get_http_response_code($url) {
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_NOBODY, true);
curl_setopt($handle, CURLOPT_HEADER, true);
curl_setopt($handle, CURLOPT_HTTPGET, true);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
/* Get the HTML or whatever is linked in $url. */
$response = curl_exec($handle);
/* Check for 404 (file not found). */
$httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if($httpCode == 200 || $httpCode == 300 ) {
echo "url buscada OK : " . $url . "status: ".$httpCode."<br>";
}else{
echo "url buscada : " . $url . "status: ".$httpCode."<br>";
}
curl_close($handle);
}
$text = trim($_POST['textareaname']);
$textAr = explode("\n", $text);
$textAr = array_filter($textAr, 'trim'); // remove any extra \r characters left behind
foreach ($textAr as $line) {
sleep(1);
get_http_response_code($line);
}
?>
<form action="" method="POST" role="form">
<legend>Form title</legend>
<div class="form-group">
<label for="">label</label>
<textarea name="textareaname" id="input" class="form-control" rows="15" required="required"></textarea>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
我认为$ scope。$ on('$ destroy'...)可以防止这种情况发生,但显然不是。
导航视觉:
$scope.$on('$ionicView.beforeEnter', function(){
// some none related stuff here.
}) ;
// custom back button to send user to master Rides tab no matter how many subviews they navigate to
//
//
var doCustomBack = function() {
$state.transitionTo('tab.rides');
};
// override soft back
// framework calls $rootScope.$ionicGoBack when soft back button is pressed
var oldSoftBack = $rootScope.$ionicGoBack;
$rootScope.$ionicGoBack = function() {
doCustomBack();
};
var deregisterSoftBack = function() {
$rootScope.$ionicGoBack = oldSoftBack;
};
// override hard back
// registerBackButtonAction() returns a function which can be used to deregister it
var deregisterHardBack = $ionicPlatform.registerBackButtonAction(
doCustomBack, 101
);
// cancel custom back behaviour
$scope.$on('$destroy', function() {
deregisterHardBack();
deregisterSoftBack();
});
我的应用程序顶部是
Tab A (controller: tabA)
-> Sub Tab A1 (controller: subTabA) <- above backbutton overrides here
Tab B (controller: tabB)
-> Sub Tab B1 (controller: subTabB)
Tab C (controller: tabC)
-> Sub Tab C1 (controller: subTabC)
Tab D (controller: tabD)
答案 0 :(得分:0)
问题是$ destroy在状态改变之前没有足够快地触发。所以转到这个:
var oldSoftBack = $rootScope.$ionicGoBack
更改为:
$rootScope.oldSoftBack = $rootScope.$ionicGoBack ;
$scope.$on('$destroy'...)
使用此:
var backStateChangeWatcher = $rootScope.$on('$stateChangeStart', function () {
if($rootScope.oldSoftBack){
deregisterHardBack();
deregisterSoftBack();
// Un-register watcher
backStateChangeWatcher();
}
}) ;
&#13;