Device back button is not working on my Ionic project when i click on device back button it will exit


#1

when i am use cordovajs that time i click on device back button automatically closed please go through

document.addEventListener(“deviceready”, onDeviceReady, false);

function onDeviceReady() {
	alert("Device ready");       
    document.addEventListener("backbutton", onBackKeyDown, false);
}

// Handle the back button
function onBackKeyDown() {
	//alert("Device back button is not working");
	//if(window.location.when =='/Home'){
		// if ($routeProvider.current.name == "/Home") {
	     if($location.path =='/Home'){
        var action= confirm("Do you want to Exit?");
         if(action){
            navigator.app.exitApp();
          }//no else here just if
  
  }else{
        $ionicHistory.nextViewOptions({
             disableBack: true
            });
	  $routeProvider.path.go('/Home');
		//ionic.Platform.exitApp();
	}
	//alert("go back");
	  //navigator.app.backHistory();
}