スコープ変数が割り当てられていない理由がわかりません。コールバックで
<script src="https://js.paystack.co/v1/inline.js"></script>
<button type="button" ng-click="checkout()">Checkout</button>
<div ng-show='txref'>
<h2>Payment successful!</h2> Transaction reference: {{txref}}
</div>
JS
//this function triggers when the button above is clicked. Everything else except assigning the reference to $scope.txref
$scope.checkout = function() {
var handler = PaystackPop.setup({
key: 'pk_test_1c828c1b8d9a98232c90d7aa6c418953c8150096',
email: '[email protected]',
amount: 10000 * 100,
ref: Math.floor((Math.random() * 100000) + 1),
callback: function(response){
console.log(response.reference) //works
alert(response.reference) //works
$scope.txref = response.reference; //doesn't work until you click the button again
},
onClose: function(){
alert('window closed');
}
});
handler.openIframe();
}
すべては$ scope.txrefへの参照を割り当てるため除いて動作します。作業を拒否しますが、もう一度ボタンをクリックするとすべて正常です。何が悪いのか分かりません。
txrefを開始します。 '$ scope.txref = ''、' – taguenizy