Pass data with $state.go

If the params aren’t in the URL, like this:

$stateProvider.state('login', {
  url: '/login/:experience/:context',
  templateUrl: 'templates/login.html',
  controller: 'userController'
});

I think you might need to define a params array in the state, like this:

$stateProvider.state('login', {
  url: '/login',
  params: [
     'experience', 'context'
  ],
  templateUrl: 'templates/login.html',
  controller: 'userController'
});

That should allow you to use your $state.go like you want.

$state.go('login', { experience: experience_id, context: 'login' });

I haven’t tried this so I might be totally wrong.

4 Likes