I need to pass and recieve two parameters to the state I want to transit to using ui-sref of ui-router.
Something like using the link below for transiti
You don't necessarily need to have the parameters inside the URL.
For instance, with:
$stateProvider
.state('home', {
url: '/',
views: {
'': {
templateUrl: 'home.html',
controller: 'MainRootCtrl'
},
},
params: {
foo: null,
bar: null
}
})
You will be able to send parameters to the state, using either:
$state.go('home', {foo: true, bar: 1});
// or
Go!
Of course, if you reload the page once on the home state, you will loose the state parameters, as they are not stored anywhere.
A full description of this behavior is documented here, under the params row in the state(name, stateConfig) section.