我可以在输入字段的自定义指令中获取$ scope

时间:2015-06-17 11:48:28

标签: angularjs angularjs-directive angularjs-scope

我正在使用angular-payment来实施付款系统。现在我想要的是仅允许VisaMasterCard。我正在使用Custom Directive

以下是代码:

<form class="col-xs-12 row" name="addCardForm" novalidate data-ng-hide = buyCreditsCtrl.useSavedCard>
<fieldset data-ng-disabled="buyCreditsCtrl.buyCreditsStep === buyCreditsCtrl.VERIFYING_CARD">
    <div class="col-xs-6">
        <div class="form-group"
             required=""
             data-ng-class="{'has-error':addCardForm.holderName.$dirty && addCardForm.holderName.$invalid}">
            <label for="paymenstCardHolder">Card Holder's Name</label>
            <input id="paymenstCardHolder"
                   type="text"
                   required=""
                   name="holderName"
                   data-ng-model="buyCreditsCtrl.cardDetails.name"
                   class="form-control"
                   placeholder="Card Holder's Name"
                    />
        </div>
        <div class="form-group"
             data-ng-class="{'has-error':addCardForm.card.$dirty && addCardForm.card.$invalid}">
            <label for="paymentsCard">Card Number</label>
            <input id="paymentsCard"
                   required=""
                   type="text"
                   data-ng-model="buyCreditsCtrl.cardDetails.number"
                   data-payments-type-model="buyCreditsCtrl.cardDetails.type"
                   data-payments-validate="card"
                   name="card"
                   class="form-control"
                   data-payments-format="card"
                   regex-validate = "sdsdfsdf"
                   placeholder="Card Number" />
        </div>

所以基本上input id ='paymentCard我想创建一个custom directive,以便在使用Visa和MasterCard以外的卡时显示错误消息。我希望在我的自定义指令中访问$scope.type来执行验证。

0 个答案:

没有答案