1

i am working on web app that uses ui-router version 0.3.2 and angular 1.5. i am having an issue with back button, when i hit the back button the url updates to appropriate state url, but does not reloads / renders the page. The controller of the new state (updated url) does not get executed. Following is my state config

$stateProvider .state('home', { url: '/', reloadOnSearch: false, templateUrl: 'homePage.html', controller:'homeController' }) .state('home.overView', { url:'overView', reloadOnSearch: false, views: { ovSB: { templateUrl: 'searchParameterBarTemplate.html', controller: 'searchParameterBarController' } } }) .state('home.overView.result', { url:'/:docType?abc&xyz&type&user&temp1&temp2', abstract: true, reloadOnSearch: false, templateUrl: 'resultViewTemplate.html', controller : 'resultPanelController' }) .state('home.overView.result.dashboard', { url:'', reloadOnSearch: false, views: { 'chart': { templateUrl: 'chart-template.html', controller: 'chart-Controller' }, 'oVGrid': { templateUrl: 'ov-grid-template.html', controller: 'ov-grid-controller' }, 'filterGrid': { templateUrl: 'filter-stats-template.html', controller: 'filter-stats-controller' } } }) .state('home.delta',{ reloadOnSearch: false, url:'Delta', views:{ pcSB:{ templateUrl: 'search-parameterbar-delta-template.html', controller : 'search-parameterBar-delta-controller' } } }) .state('home.delta.result',{ url:'/:docType?xyz_1&abc_1&xyz_2&abc_2', reloadOnSearch: false, templateUrl: 'delta-template.html', controller : 'delta-controller' }) .state('home.details', { url: 'details', views: { detailsSB: { templateUrl: 'search-paramBar-details-template.html', controller: 'search-paramBar-details-controller' } } }) .state('home.details.result', { url: '/:documentType?abc&xyz&user&temp1&temp2', abstract: true, templateUrl: 'details-view-template.html', controller: 'details-view-controller' }) .state('home.details.result.dashboard',{ url:'', views:{ perGraph : { controller :'per-graph-controller', templateUrl: 'per-graph-template.html' }, detailsGrid: { controller: 'details-grid-controller', templateUrl: 'details-grid-controller-template.html' } } }); 

So for example if i navigate from home.overview.result.dashboard (url -> localhost:12345/overview/doctype?abc&xyz&user&temp1&temp2) state to home.details.result.dashboard state with url localhost:12345/details/doctype?abc&xyz&user&temp1&temp2 and hit backbutton, the url updates to localhost:12345/overview/doctype?abc&xyz&user&temp1&temp2 however it does not reloads/renders the page.

I believe I can you use this solution and trigger the reload, but I am looking for a better solution than this which adheres to ui router. is there something i am missing with state config / doing wrong? Any help pertaining to this would be highly appreciated. Thank you

2
  • try removing reloadOnSearch from your 'home' state Commented Jul 5, 2017 at 17:43
  • tried that, didn't solve the problem Commented Jul 5, 2017 at 18:03

1 Answer 1

1

it will be firing $stateChangeStart event. use location directive to rout it . please refer the below snippet

$rootScope.$on('$routeChangeStart', function (event,next) { $location.path(next.$$route.originalPath); }); 

this can resolve your problem. but its not the perfect solution

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.