How to pass parameters using ui-sref in ui-router to controller
I need to pass and receive two parameters to the state I want to transit to using ui-sref of ui-router.
Something like using the link below for transitioning the state to home with foo and bar parameters:
Go to home state with foo and bar parameters
Receiving foo and bar values in a controller:
app.controller('SomeController', function($scope, $stateParam) {
//..
var foo = $stateParam.foo; //getting fooVal
var bar = $stateParam.bar; //getting barVal
//..
});
I get undefined for $stateParam in the controller.
Could somebody help me understand how to get it done?
Edit:
.state('home', {
url: '/',
views: {
'': {
templateUrl: 'home.html',
controller: 'MainRootCtrl'
},
'A@home': {
templateUrl: 'a.html',
controller: 'MainCtrl'
},
'B@home': {
templateUrl: 'b.html',
controller: 'SomeController'
}
}
});