{"action":"created","issue":{"url":"https://api.github.com/repos/angular-ui/ui-router/issues/2115","labels_url":"https://api.github.com/repos/angular-ui/ui-router/issues/2115/labels{/name}","comments_url":"https://api.github.com/repos/angular-ui/ui-router/issues/2115/comments","events_url":"https://api.github.com/repos/angular-ui/ui-router/issues/2115/events","html_url":"https://github.com/angular-ui/ui-router/issues/2115","id":96370393,"number":2115,"title":"How to persist optional parameter or state data on browser back?","user":{"login":"pankajparkar","id":5320044,"avatar_url":"https://avatars.githubusercontent.com/u/5320044?v=3","gravatar_id":"","url":"https://api.github.com/users/pankajparkar","html_url":"https://github.com/pankajparkar","followers_url":"https://api.github.com/users/pankajparkar/followers","following_url":"https://api.github.com/users/pankajparkar/following{/other_user}","gists_url":"https://api.github.com/users/pankajparkar/gists{/gist_id}","starred_url":"https://api.github.com/users/pankajparkar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pankajparkar/subscriptions","organizations_url":"https://api.github.com/users/pankajparkar/orgs","repos_url":"https://api.github.com/users/pankajparkar/repos","events_url":"https://api.github.com/users/pankajparkar/events{/privacy}","received_events_url":"https://api.github.com/users/pankajparkar/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-07-21T17:19:51Z","updated_at":"2015-08-21T22:43:45Z","closed_at":"2015-07-21T18:58:42Z","body":"I'm having one parent state that has two children's state inside that I'm going to show one state based on the `URL`.\r\n\r\nOut of those two `states` one is having to parameters like `param1` and `param2`, I have use `params` option of ui-router inside state definition.\r\n\r\nState\r\n\r\n    $stateProvider.state('tabs.account', {\r\n        url: '/account',\r\n        views: {\r\n            'content@tabs': {\r\n                templateUrl: 'account.html',\r\n                controller: function($scope, $stateParams) {\r\n                    //This params are internally used to make ajax and show some data.\r\n                    $scope.param1 = $stateParams.param1;\r\n                    $scope.param2 = $stateParams.param2;\r\n                },\r\n            }\r\n        },\r\n        params: {\r\n            param1: { value: null }, //this are optional param\r\n            param2: { value: null } //because they are not used in url\r\n        }\r\n    });\r\n\r\nIf you look at my route the params option is not really introduced inside the `URL`, that's why I'm considering then as optional. \r\n\r\nProblem\r\n-------\r\n\r\nLook at plunkr, I've shown two tabs **Account** & **Survey**, \r\n\r\n 1. Click on Survey tab, then add some data in the `textarea` which are shown. \r\n 2. Click on **Go to Account** that will pass those `textarea` values to\r\n    the other **Account** tab by doing `ui-sref=\"tabs.account({param1: thing1, param2: thing2})\"` on the anchor\r\n\r\n\r\n 3. Now you will see the `param1` & `param2` values on html which has been assigned to scope from `$stateParams`\r\n 4. Now again Click on **Survey** tab, you will land on the survey page.\r\n 5. Just click browser back, you will notice that `param` value is not getting `null`.\r\n\r\n\r\n[**Problem Plunkr**][1]\r\n\r\nI believe you got what I wanted to ask, why the optional parameter value has not been store? as they have been a part of state.\r\n\r\nI know I can solve this issue by below two solutions.\r\n\r\n - By creating one service that will share data between two views.\r\n - By adding parameter inside the state URL. like `url: '/account/:param1/:param2',` (But i wouldn't prefer this)\r\n\r\nI already tried angular-ui-routers [**`sticky states`**][2] but that doesn't seems to work for me. What is the better way to this?\r\n\r\nIs there any technique that I can use for my case, Any ideas would appreciate.\r\n\r\n[**Stackoverflow Question here**][3]\r\n\r\n**Edit**\r\n\r\nSame issue appears for the data option of state, you could look at this [SO Question][4]\r\n\r\n\r\n  [1]: http://plnkr.co/edit/NF0W2apwlz7ufGSu2OCR?p=preview\r\n  [2]: http://christopherthielen.github.io/ui-router-extras/#/sticky\r\n  [3]: http://stackoverflow.com/questions/31542972/how-to-persist-optional-data-on-browser-back-in-angular-ui-router\r\n  [4]: http://stackoverflow.com/questions/31542972/how-to-persist-optional-data-on-browser-back-in-angular-ui-router"},"comment":{"url":"https://api.github.com/repos/angular-ui/ui-router/issues/comments/133581591","html_url":"https://github.com/angular-ui/ui-router/issues/2115#issuecomment-133581591","issue_url":"https://api.github.com/repos/angular-ui/ui-router/issues/2115","id":133581591,"user":{"login":"christopherthielen","id":2053478,"avatar_url":"https://avatars.githubusercontent.com/u/2053478?v=3","gravatar_id":"","url":"https://api.github.com/users/christopherthielen","html_url":"https://github.com/christopherthielen","followers_url":"https://api.github.com/users/christopherthielen/followers","following_url":"https://api.github.com/users/christopherthielen/following{/other_user}","gists_url":"https://api.github.com/users/christopherthielen/gists{/gist_id}","starred_url":"https://api.github.com/users/christopherthielen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/christopherthielen/subscriptions","organizations_url":"https://api.github.com/users/christopherthielen/orgs","repos_url":"https://api.github.com/users/christopherthielen/repos","events_url":"https://api.github.com/users/christopherthielen/events{/privacy}","received_events_url":"https://api.github.com/users/christopherthielen/received_events","type":"User","site_admin":false},"created_at":"2015-08-21T22:43:45Z","updated_at":"2015-08-21T22:43:45Z","body":"Is there a bug? This is an issue tracker for bugs. "}}