Nir*_*ole 3 javascript angularjs angular-ui-router
我正在开发AngularJS应用程序.我正在尝试将值发送$state.go到不同的状态.我正在尝试如下.
这是我的状态:
$stateProvider
.state('Registration.OTPVerification', {
url: '/RegistrationOTPVerification',
templateUrl: 'Registration/RegistrationOTP.html',
controller: 'RegistrationOTPVerification'
});
Run Code Online (Sandbox Code Playgroud)
我正在尝试如下.
var customerid = response.data.ID;
var OTP = response.data.OTP;
$state.go('Registration.OTPVerification', customerid,OTP);
Run Code Online (Sandbox Code Playgroud)
我试图在下面的控制器中接收参数.
(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);
}]);
})();
Run Code Online (Sandbox Code Playgroud)
我无法接收参数.任何帮助,将不胜感激.谢谢.
tan*_*may 13
你需要有这些params,以便能够发送它们state.像这样:
$stateProvider
.state('Registration.OTPVerification', {
url: '/RegistrationOTPVerification',
params: {
customerid: null,
OTP: null
},
templateUrl: 'Registration/RegistrationOTP.html',
controller: 'RegistrationOTPVerification'
});
Run Code Online (Sandbox Code Playgroud)
现在,您可以使用$state.go以下内容:
$state.go('Registration.OTPVerification', {
customerid: 123,
OTP: 2323
});
Run Code Online (Sandbox Code Playgroud)
最后,您可以访问他们你正在使用的方式$stateParams.customerid和$stateParams.OTP但要确保你已经$stateParams注入就像你$state和$translate注射.
| 归档时间: |
|
| 查看次数: |
6983 次 |
| 最近记录: |