7

When user clicks some cancel action in hybrid (Angular JS) application, for the first time the history.back not working in my application. If once I press device back button and try again then it works well.

I tried all below possibilities

$window.history.back();

// Normal window
window.history.back();
 and
window.histroy.go(-1); return false;

// HTML onclick function
<div ng-click="Javascript:history.back()">back</div>
<div ng-click="Javascript:history.go(-1)">back</div>

Non of the above solutions were worked.

Braiam
  • 1
  • 11
  • 47
  • 78
Sampath Kumar
  • 4,433
  • 2
  • 27
  • 42
  • Are you using any framework like ionic for building this hybrid application ? If so, they have a customize function $ionicHistory.goBack(); http://ionicframework.com/docs/api/service/$ionicHistory/ – trungk18 Oct 08 '16 at 04:08
  • @trungk18 - It is built on simple angularJS function. No framework been used (Angular material been used for material design) – Sampath Kumar Oct 08 '16 at 06:59
  • So as my understanding, once you open the application It will show up a home state. Then user touches somewhere to change the state. On this state, you touch back button on the devices. Then you capture this event and handle to go back to homepage but not successfully for this first time ? Can you also show some of your code for handling the back button on the devices ? – trungk18 Oct 08 '16 at 07:02
  • @trungk18 I have given the source in the question, and here is that $window.history.back(); – Sampath Kumar Oct 09 '16 at 07:04
  • @SampathKumar : you can debug your device using chrome extention ADB(https://chrome.google.com/webstore/detail/adb/dpngiggdglpdnjdoaefidgiigpemgage) – Anurag Oct 12 '16 at 18:37

0 Answers0