javascript - How to send parameters in Angularjs $state.go? -


i developing angularjs application. trying send values in $state.go different states. trying below.

this state:

$stateprovider .state('registration.otpverification', {     url: '/registrationotpverification',     templateurl: 'registration/registrationotp.html',     controller: 'registrationotpverification' }); 

i trying below.

var customerid = response.data.id; var otp = response.data.otp; $state.go('registration.otpverification', customerid,otp); 

i trying receive parameters in below controller.

(function () {     angular.module('roslpapp').controller('registrationotpverification', ['$scope', '$http', '$translatepartialloader', '$translate', '$state', function ($scope, $http, $translatepartialloader, $translate, $state, $stateparams) {         var customerid = $stateparams.customerid;         var otp = $stateparams.otp;         alert(customerid);     }]); })(); 

i not able receive parameters. appreciated. thank you.

you need have params in order able send them through state. this:

$stateprovider .state('registration.otpverification', {     url: '/registrationotpverification',     params: {         customerid: null,         otp: null     },     templateurl: 'registration/registrationotp.html',     controller: 'registrationotpverification' }); 

now, can use $state.go following:

$state.go('registration.otpverification', {     customerid: 123,     otp: 2323 }); 

finally, can access them way using $stateparams.customerid , $stateparams.otp make sure have $stateparams injected have $state , $translate injected.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -