Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardware back button different action than ion-nav-buttons #145

Open
fgagneten opened this issue Nov 19, 2017 · 2 comments
Open

Hardware back button different action than ion-nav-buttons #145

fgagneten opened this issue Nov 19, 2017 · 2 comments

Comments

@fgagneten
Copy link

fgagneten commented Nov 19, 2017

On click hardware back button in an specific view I get:

[INFO:CONSOLE(11706)] "[native transition] same state transition are not possible", source: file:///android_asset/www/bower_components/angular/angular.js (11706)

What is weird that if I click in the same view the ion-nav-buttons back button, works perfectly.

I have 3 view, the view what I'm talking about is view 2.
If I go from view 1 to view 2 and then click on hardware back button goes again to view 1 thats perfect.

The problem is if I go to view 2 from view 1, then I go to view 3 and after that I click back button (or ion-nav-bar) in view 3 I go back to view 2. There is the problem when I click only hardware back button on view 2 after go back from view 3.

To sum up:

  • View1 -> state.go(view2) -> View2 -> state.go(view1) -> View 1✔

  • View1 -> state.go(view2) -> View2 -> state.go(view3) -> View 3 -> state.go(view2) -> View 2 state.go(view1) with hardware back button -> "[native transition] same state transition are not possible"❌

This is my code:

HTML

<ion-view view-title="Title">
    <ion-nav-buttons side="left">
        <a class="button button-icon ion-android-arrow-back" ng-click="vm.volver()"></a>   
    </ion-nav-buttons>
    <ion-content> 
         ...
         ...
    </ion-content>

CONTROLLER:

(function() {
	'use strict';

	angular
		.module('package.complex')
		.controller('ComplexController', ComplexController);

	ComplexController.$inject = ['$state', 'complexService','$rootScope', '$ionicModal', '$ionicPlatform', '$ionicNativeTransitions'];

	function ComplexController($state, complexService,$rootScope, $ionicModal, $ionicPlatform, $ionicNativeTransitions) {
		var vm = this;
		vm.volver = volver;
	
		$ionicPlatform.registerBackButtonAction(function () {
			console.log("back button was clicked");
			volver();
		}, 100)

                    function volver() {
			console.log("method was called");
			$ionicNativeTransitions.stateGo('home', {session: 1}, {}, {
				"type": "slide",
				"direction": "right", // 'left|right|up|down', default 'left' (which is like 'next')
				"duration": 500, // in milliseconds (ms), default 400
			});
		};

MODULE

(function() {
	'use strict';

	angular
		.module('package.complex', [
			'ionic',
			'ngCordova'
		])
		.config(function($stateProvider) {
			$stateProvider
				.state('complexes', {
					url: '/usuario/complexes',
					templateUrl: 'scripts/package/complex/complex.html',
					controller: 'ComplexController as vm'
				});
		});
})();

Another thing: if I set in my module:

cache:false

Hard back button and ion-nav-buttons works perfectly. Sound weird?

Also, you can see a few logs there, well, on click hardware back button neither of them was called. Just when I click on ion-nav-buttons

Please, Someone can help me? I need to solve the problem ASAP.

EDIT: On hardware back button click, the state to go is the current state, so the script is not taking into account the new state that I'm sending.

Thanks

@francozini2
Copy link

+1 same issue

@cuchujero
Copy link

cuchujero commented Nov 26, 2017

+1 Same problem here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants