我正在关注this tutorial。我已经实现了电话验证部分,并且登录页面和确认$state.go
之后没有重定向。代码非常简单,我不明白为什么会发生这种情况。
// confirmation controller:
export default class ConfirmationCtrl extends Controller {
constructor() {
super(...arguments);
this.phone = this.$state.params.phone;
}
confirm() {
if (_.isEmpty(this.code)) return;
Accounts.verifyPhone(this.phone, this.code, (err) => {
if (err) return this.handleError(err);
this.$state.go('profile');
});
}
handleError(err) {
this.$log.error('Confirmation error', err);
this.$ionicPopup.alert({
title: err.reason || 'Confirmation failed',
template: 'Please try again',
okType: 'button-positive button-clear'
});
}
}
ConfirmationCtrl.$name = 'ConfirmationCtrl';
ConfirmationCtrl.$inject = ['$state', '$ionicPopup', '$log'];
路线:
// relevant part from routes.js
.state('confirmation', {
url: '/confirmation/:phone',
templateUrl: confirmationTemplateUrl,
controller: 'ConfirmationCtrl as confirmation'
})
.state('profile', {
url: '/profile',
templateUrl: profileTemplateUrl,
controller: 'ProfileCtrl as profile',
resolve: {
user: this.isAuthorized
}
})
没有错误消息。我不明白自己在做什么错,一切似乎都井井有条,我知道验证已通过,因为我尝试在执行以下操作后找出问题所在:
Accounts.verifyPhone(... yada yada ...)
var verification = Accounts.isVerified();
if verification { console.log('verified:', verification); this.$state.go('profile') }
因此,问题肯定出在$ state.go上,它什么也不做,没有错误或警告,也没有任何内容。怎么了?