0

I want to maintain state of user-data. So that even on reload I can show the exact result to user using stateParams but without showing in URL(query string) in browser. How can I achieve this?

Partha Sarathi Ghosh
  • 10,936
  • 20
  • 59
  • 84

1 Answers1

0
var app = angular.module('rootApp', [
    'ui.router'
]);

pp.config(function ($stateProvider, $urlRouterProvider, $locationProvider, $httpProvider) {
    $urlRouterProvider.otherwise('/signin');
    $stateProvider
        .state('user', {
            url: '/home',
         params: {
                 guid: null,
                 role: NaN
                 },
         templateUrl: 'Components/default/home.html',
         controller: 'rootCtrl',
         data: {
                requireLogin: true
            }
        })

});

now you can navigate to this state from href tag like:

<a ui-sref="user({guid: 1, role: 'anyrole'})">

or by method :

$state.go('user', {param: {guid: 1, role: 'anyrole'}});
Sheelpriy
  • 1,675
  • 17
  • 28