在我的AngularJS控制器中,我有这个:
....
stripeResponseHandler = function (status, response) {
if(response.error) {
Toaster.pop('rejected', 'cross', 'We could not validate your card.');
}
}
$scope.handleNewCard = function () {
Stripe.card.createToken({
number: $scope.number,
cvc: $scope.cvc,
exp_month: $scope.exp_month,
exp_year: $scope.exp_year,
name: $scope.name,
address_line1: $scope.address_line1,
address_line2: $scope.address_line2,
address_zip: $scope.address_postcode,
address_city: $scope.address_city,
address_country: $scope.address_country
}, stripeResponseHandler);
};
...
在我看来,我有这个:
.col-xs-6
a.btn.large.blue.pull-left(ng-click='handleNewCard()')
| Save
问题是只有在我单击“保存”按钮两次时才会处理回调函数。 奇怪的是,如果我只是在回调中执行console.log,它每次都会显示它,但Toaster.pop仅在我单击保存按钮两次时才会显示。