我正在使用Braintree Hosted Fields在我的 Angular 应用程序中。当应用加载时,braintree.setup('TOKEN', 'customer', {})
按预期工作。 onReady
正确触发。
这是我的 Controller :
angular.module('braintree')
.controller('BraintreeCtrl', [
function() {
var self = this;
self.setup = function() {
console.log('setup braintree');
braintree.setup('myBTtoken', 'custom', {
id: 'braintreeForm',
onReady: function() {
console.log('on ready');
},
hostedFields: {
styles: {},
number: {
selector: '#card-number',
placeholder: 'Card number'
},
cvv: {
selector: '#card-cvv',
placeholder: 'CVV'
},
expirationMonth: {
selector: '#card-expiration-month',
placeholder: 'MM'
},
expirationYear: {
selector: '#card-expiration-year',
placeholder: 'YY'
},
postalCode: {
selector: '#card-postal',
placeholder: 'Postal code'
}
}
});
}
}
]);
View ( Jade ):
form(name='braintreeForm', id='braintreeForm', novalidate, ng-init='ctrl.setup()')
.form-group
label Card Number
#card-number
.form-group
label CVV
#card-cvv
.form-group
label Expires
#card-expiration-month
.form-group
#card-expiration-year
.form-group
label Zip Code
#card-postal
button(type='submit') Submit
但是,当我离开此页面,然后返回到 BraintreeCtrl
触发的状态时,onReady
永远不会触发,并且我无法输入任何数据.
当我回到 Braintree 状态时如何重新设置 Braintree?
最佳答案
我在 Braintree 从事 JavaScript SDK 工作
到目前为止,还没有官方支持的机制。这是我们意识到的一个问题,我们将在未来的版本中提供解决方案。不幸的是,我无法提供这项工作的时间表。
同时,我建议联系我们的支持团队 ( [email protected] ) 并密切关注我们的 Github 上的相关主题。 。同样,虽然没有官方支持的解决方案,但人们已经找到了一些interesting workarounds .
很抱歉,我没有更好的消息,但我们感谢您提出这个问题。
关于angularjs - Braintree onReady 未在 Angular 应用程序中触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30768401/