I'm trying to go very simply to another state programatically and pass parameters, so:
$stateService.go('login', {
messages: [{
service: 'Auth',
type: 'error',
msg: "Your session has expired. Please log in to continue..."
}]
});
$stateService is to avoid circular dependancy between ui-router and state (both of which use $http)
var $stateService = $injector.get('$state');
This is the login state, as loaded into $stateProvider:
angular
.module('kitchenapp')
.config(['$stateProvider', function ($stateProvider) {
$stateProvider
.state('login', {
url: '/login',
templateUrl: 'views/login/login.html',
controller: 'LoginCtrl',
controllerAs: 'vm'
});
}]);
When I go to the login controller, however
angular
.module('kitchenapp.controllers')
.controller('LoginCtrl', LoginCtrl);
LoginCtrl.$inject = ['$location', 'Auth', 'toastr', '$stateParams', '$log'];
function LoginCtrl($location, Auth, toastr, $stateParams, $log) {
var vm = this;
angular.extend(vm, {
name: 'LoginCtrl',
messages: $stateParams.messages,
...
$stateParams.messages is empty. What am I doing wrong?