A
A
Artem Shchurin2016-09-07 17:08:38
JavaScript
Artem Shchurin, 2016-09-07 17:08:38

How to save information when transitioning between ui-router states?

Good afternoon!
How to store information between pages when going forward back?
Angular 1.5 + ui-router
Router code

function routerConfig($stateProvider, $urlRouterProvider) {
    $stateProvider
      .state('home', {
        url: '/',
        templateUrl: 'app/main/main.html',
        controller: 'MainController',
        controllerAs: 'main'
      })
      .state('result', {
        url: '/result',
        templateUrl: 'app/result/result.html',
        controller: 'ResultController',
        controllerAs: 'result',
        params: {
          searchResult: null
        }
      })
      .state('page', {
        url: '/page',
        templateUrl: 'app/page/page.html',
        controller: 'PageController',
        controllerAs: 'page'
      });
    
    $urlRouterProvider.otherwise('/');
  }

On the home page I load the data and using $state.go() I transfer the data to the result page, there is a table, in the table when I click on the link I get to the page page, but if I go back I get an empty table
How to store history?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Zolotykh, 2016-09-07
@zolotykh

Use factories/services for data.

N
napa3um, 2016-09-07
@napa3um

https://developer.mozilla.org/en/docs/Web/API/Hist...
https://docs.angularjs.org/api/ng/service/$locatio...
https://github.com /angular-ui/ui-router/wiki/url-r...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question