Skip to main content

After testing different proposals  , I found that the easiest way is often the best.

If you use angular ui-router and that you need a button to go back best is this:

<button onclick="history.back()">Back</button> 

or

<a onclick="history.back()>Back</a> 

// Warning don't set the href or the path will be broken.

Explanation.: Suppose a standard management application. Search objetobject -> View objetobject - >> Edit object

Using the angular solutions From this state :

Search -> View -> Edit

To :

Search -> View

Well that's what we wanted except if now you click the browser back button you'll be there again :

Search -> View -> Edit

And that is not logical

However using the simple solution

<a onclick="history.back()"> Back </a> 

from :

Search -> View -> Edit

after click on button :

Search -> View

after click on browser back button :

Search

Consistency is respected. :-)

After testing different proposals  , I found that the easiest way is often the best.

If you use ui-router and that you need a button to go back best is this:

<button onclick="history.back()">Back</button> 

or

<a onclick="history.back()>Back</a> 

// Warning don't set the href or the path will be broken.

Explanation. Suppose a standard management application. Search objet -> View objet - > Edit object

Using the angular solutions From this state :

Search -> View -> Edit

To :

Search -> View

Well that's what we wanted except if now you click the browser back button you'll be there again :

Search -> View -> Edit

And that is not logical

However using the simple solution

<a onclick="history.back()"> Back </a> 

from :

Search -> View -> Edit

after click on button :

Search -> View

after click on browser back button :

Search

Consistency is respected. :-)

After testing different proposals, I found that the easiest way is often the best.

If you use angular ui-router and that you need a button to go back best is this:

<button onclick="history.back()">Back</button> 

or

<a onclick="history.back()>Back</a> 

// Warning don't set the href or the path will be broken.

Explanation: Suppose a standard management application. Search object -> View object -> Edit object

Using the angular solutions From this state :

Search -> View -> Edit

To :

Search -> View

Well that's what we wanted except if now you click the browser back button you'll be there again :

Search -> View -> Edit

And that is not logical

However using the simple solution

<a onclick="history.back()"> Back </a> 

from :

Search -> View -> Edit

after click on button :

Search -> View

after click on browser back button :

Search

Consistency is respected. :-)

Source Link
bArraxas
  • 674
  • 7
  • 14

After testing different proposals , I found that the easiest way is often the best.

If you use ui-router and that you need a button to go back best is this:

<button onclick="history.back()">Back</button> 

or

<a onclick="history.back()>Back</a> 

// Warning don't set the href or the path will be broken.

Explanation. Suppose a standard management application. Search objet -> View objet - > Edit object

Using the angular solutions From this state :

Search -> View -> Edit

To :

Search -> View

Well that's what we wanted except if now you click the browser back button you'll be there again :

Search -> View -> Edit

And that is not logical

However using the simple solution

<a onclick="history.back()"> Back </a> 

from :

Search -> View -> Edit

after click on button :

Search -> View

after click on browser back button :

Search

Consistency is respected. :-)