0

I have a products table, I make an advanced research, click on a line to see details and then click on cancel button to go back to the list, all my research input will be empty...

Is it possible to go back where I was ? I mean to my previous research or previous page? I'm trying to do this based on ng-models, is there another way?

Thank you.

slama
  • 85
  • 2
  • 11
  • Please, add some code in order to see what you have done so far, and what you want to do specifically. What you describe can be accomplished in many ways. Cheers! – lealceldeiro Dec 14 '16 at 17:44
  • May i know which routing you are using. I mean 'ng-route' or 'ui-route'? – shubham bahuguna Dec 14 '16 at 17:51
  • The [History API](https://developer.mozilla.org/en-US/docs/Web/API/History) and the [popstate event](https://developer.mozilla.org/en-US/docs/Web/Events/popstate) are used for that. In AngularJS those APIs are uses by [ngRoute](https://docs.angularjs.org/api/ngRoute) in HTML 5 mode. – georgeawg Dec 14 '16 at 18:03
  • @AsielLealCeldeiro i didn't get over with working solution so i can't post clarify this with code.. – slama Dec 15 '16 at 08:27
  • @shubhambahuguna i'm using ui-route – slama Dec 15 '16 at 08:28
  • @slama have you checked my answer? – shubham bahuguna Dec 15 '16 at 18:03
  • @shubhambahuguna yes, please see my comment below. :) – slama Dec 19 '16 at 08:32
  • @georgeawg by saying previous state, i mean, i don't want to loose my research's result if i consult one row's details and go back to that result. – slama Dec 20 '16 at 11:37
  • Use [AngularJS services](https://docs.angularjs.org/guide/services) to hold data for life of the application. Use the [Web Storage API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API) to hold data for longer. – georgeawg Dec 20 '16 at 18:37

1 Answers1

0

these solutions might help you.

Angular - ui-router get previous state

How do I get the Back Button to work with an AngularJS ui-router state machine?

http://blogs.candoerz.com/question/182248/angular-ui-router-get-previous-state.aspx

more or less same answer in all of these links i found.

$rootScope.$on('$stateChangeSuccess', function (ev, to, toParams, from, fromParams) {
   //assign the "from" parameter to something
});
Community
  • 1
  • 1
shubham bahuguna
  • 384
  • 4
  • 16
  • it works for to and from but toParams and fromParams are always empty. – slama Dec 19 '16 at 08:26
  • i don't know if i well explained what i want to do or not. in fact i don't want to loose my advanced research's result if i consult a row's details and go back to that result.. you see? – slama Dec 19 '16 at 08:31