Angularjs: $window.history.go not working in ios

371 Views Asked by At

My webapp is using angularjs-1.5.11 and we are using below line to go back in the application:

$window.history.go(-1)

This is not working in ios 10.2.1 I've tried the below, but didn't work

window.history.go(-1) 
history.back()
navigator.app.backHistory

I saw other posts which suggests to disable hashListening but I'm not sure how to do this in angularjs.

Anyone has suggestions please.

2

There are 2 best solutions below

1
Ram_T On

Try do it using jquery

  $(document).bind('mobileinit', function () {

      $.mobile.hashListeningEnabled = false;
      $.mobile.linkBindingEnabled = false;

  });

And also make sure that your files in this order

<script src="jquery.js"></script>
<script src="custom-scripting.js"></script> <!-- Note your script before jqm -->
<script src="jquery-mobile.js"></script>
1
Ved Rauniyar On

Use the below code

<button type="button" onclick="goBack()">Go To Back</button>