How to implement history.back() in angular.js

前端 未结 10 1737
南笙
南笙 2020-11-27 09:37

I have directive which is site header with back button and I want on click to go back to the previous page. How do I do it in the angular way?

I have tried:

10条回答
  •  南笙
    南笙 (楼主)
    2020-11-27 10:28

    In case it is useful... I was hitting the "10 $digest() iterations reached. Aborting!" error when using $window.history.back(); with IE9 (works fine in other browsers of course).

    I got it to work by using:

    setTimeout(function() {
      $window.history.back();
    },100);
    

提交回复
热议问题