title: How to preserve ui-router parameters on browser refresh
body: <p>am using angular ui-router to manage states of my SPA.
  I have this route:</p>
  
  
  
  <pre><code>    .state('index.administration.security.roleEdit', {
                  url: '/roleEdit',
                  templateUrl: 'app/administration/security/role/roleEdit.html',
                  controller: 'roleEditCtrl',
                  controllerAs: 'roleEditCtrl',
                  params: { data: null },
                  resolve: {
                      role: function ($stateParams) {
                          return angular.fromJson($stateParams.data);
                      },
                      modules: function (securityService) {
                          return securityService.getAllModules();
                      }                       
                  }
              })
  </code></pre>
  
  <p>Also, I'm passing 'data' parameter as json object to the state.
  Now when i first load this state, everything is fine.
  But when i do browser refresh (F5 key) the $stateParams.data is null in the resolve function of the state.</p>
  
  <p>How can I solve this?
  I see these possible solutions:
  1. persist somehow parameters
  2. override browser refresh (don't know how) to stop the browser refreshing the app.
  3. on refresh goto other sibling state.</p>
  
  <p>Please help</p>
  
  <p><strong>UPDATE</strong>
  Ok, I set data like this:</p>
  
  <pre><code>vm.editRole = function(roleId){
       var role = dataService.getRoleById(roleId).then(function(result){
             $state.go('roleEdit', {data:angular.toJson(result)});
             });
  }
  </code></pre>
  
  <p><strong>UPDATE 2</strong>
  The roleEdit Controller looks like this:</p>
  
  <pre><code>(function(){
      angular.module('app.administration').controller('roleEdit', 
      ['role','modules', '$scope', 'securityService', '$state', roleEditCtrl]);
  
      function roleEditCtrl('role', 'modules',$scope, securityService, $state){
          var vm = this;
          vm.roles = roles;
          vm.originalRole = angular.copy(role);
          vm.modules=modules;
          vm.saveChanges = _saveChanges;
          vm.cancel = _cancel;
  
          return vm;
  
          function _saveChanges(){
              securityService.UpdateRole(vm.role).then(function(result){
                  $staste.go('^.roles');
              }
          }
  
          function _cancel(){
              vm.role = angular.copy(vm.originalRole);
              $sscope.roleEditForm.$setPristine();            
          }
      }
  })();
  </code></pre>