S
S
Stanislav_Bykov2018-07-18 16:49:56
Angular
Stanislav_Bykov, 2018-07-18 16:49:56

How to find the previous url of the router?

Good afternoon!
There is an application written in Angular (the first one), page navigation is carried out using ngRoute. It is necessary to add a Back button ($window.history.back();), but that it would appear only if the transition was made through the pages of the application. Tried to do it by parsing $document[0].referrer but its value is always empty. How can I find out the address of the previous page that ngRoute loaded?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Kumanin, 2018-07-19
@jackkum

app.run(function ($rootScope) {
  $rootScope.$on('$routeChangeStart', function (event, current, previous, reject) {
    // previous
  })
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question