Luca Romano
Luca Romano

Reputation: 118

AngularJS $state.go pass always empty valure for parameter

I've tried to pass one parameter white $stete.go.

ROUTER

$stateProvider.state('login.signin', {
    url: '/signin',
    params: {
        login_event: ''
    },
    templateUrl: "assets/views/login_login.html",
    title: 'Login',
    resolve: loadSequence('moment', 'userLoginCtrl')
});

CALLING

$state.go('login.signin', { login_event: "session_expired"});

TEST

console.log('toParams: ');
console.log(toParams);

console.log('fromParams: ');
console.log(fromParams);

console.log('$stateParams: ');
console.log($stateParams);

console.log('$state.params: ');
console.log($state.params);

Even if I pass a value in calling, the value I get in "toParams" is always the default value.

I've tried many many time to get a value, but "toParams" have only the default value.

Thanks for help.

Upvotes: 1

Views: 416

Answers (1)

Pankaj Parkar
Pankaj Parkar

Reputation: 136144

You current implementation(shorthand implementation) of params object, which will not consider the parameter pass from the $stateParms, it will default value of login_event to ''. You should change your params object implementation so that default value would be '' like value: '' if its not passed.

Docs Link

Code

params: {
    login_event: {
       value: ''
    }
},

Upvotes: 1

Related Questions