user1469734
user1469734

Reputation: 801

$stateProvider get $stateParams in .go()

I wanna access some parameters for a $state:

$state.go('tabs.foobar', { go: 'yo' });

So I can access the "go" parameter, and alert the 'yo'.

.controller('foobarCtrl', function($scope, $window, $stateParams) {
    if($stateParams.go) {
      alert($stateParams.go);
    }

But it's not working with the $stateProvider, what am I missing?

$stateProvider.state('tabs.foobar', {
  url: '/foobar',
  cache: false,
  views: {
    'tab3': {
      templateUrl: 'templates/foobar.html',
      controller: 'foobarCtrl'
    }
  }
});

Upvotes: 1

Views: 91

Answers (1)

Darth Android
Darth Android

Reputation: 3502

You need to declare the go parameter as a URL Path or query parameter:

url: '/foobar/:go',

OR

url: '/foobar?go',

Upvotes: 3

Related Questions