Controlling going back using $rootScope.$ionicGoBack

Hi there,

I’m trying to control the back-button using a overload of the $rootScope.$ionicGoBack function in one of my controllers.
The basics of it is, present a $ionicPopup.confirm to the user, and only when the user clicks ok should the go-back be done. This has proven impossible to do so far because the $ionicHistory.goBack function is always called, even though my popup does display, but only after the goBack action has been completed and the previous view is shown on the device.

In my controller I inject $rootScope, and then overload the $ionicGoBack function like this

 $rootScope.$ionicGoBack = function (backCount) {
	var confirmPopup = $ionicPopup.confirm({
					title: 'Gaan Terug',
					template: 'Is jy seker jy wil terug gaan ? Alle antwoorde vir die sessie van die aanlegtoets gaan nie gestoor word nie.'

	confirmPopup.then(function (res) {
		if (res) {
		} else {
			//do nothing


I also tried using a $ionicHistory.goBack(0) call as the first line in the function above since the documentation states that if the parameter is 0 or more the goBack method will do nothing, but this does not work either.

Any ideas or comments will be appreciated.