【发布时间】:2015-06-11 17:31:35
【问题描述】:
我正在使用angular-credit-cards 创建信用卡表单。信用卡号有以下设置:
<!--... form stuff ...-->
<div class="form-group" ng-class="{'has-success': donationForm.ccNumber.$valid}">
<label for="ccNumber">Credit Card Number</label>
<div class="input-group">
<input type="text" class="form-control" name="ccNumber" ng-model="credit_card.number" cc-number cc-eager-type/>
<div class="input-group-addon">{{donationForm.ccNumber.$ccEagerType}}</div>
</div>
</div>
<!--... more form stuff ...-->
提交此表单时,它会调用一个创建 Paypal 付款的函数。 Paypal 付款需要信用卡类型。 angular-credit-cards 根据 cc-number 指令所属的输入动态确定信用卡类型,并将其存储在输入的 $ccEagerType 中。但是,如何从输入中获取这些数据并将其交给控制器?
我尝试了以下方法:
<input type="hidden" ng-model="credit_card.type" ng-value="donationForm.ccNumber.$ccEagerType"/>
但是donationForm.ccNumber.$ccEagerType 没有绑定到credit_card.type。
提前致谢。
【问题讨论】:
标签: javascript angularjs validation paypal