html

时间:2016-12-21 07:00:22

标签: javascript jquery angularjs html5

我需要显示所需的属性(asterix),具体取决于所选单选按钮的值。如何使用javascript实现这一目标?

<p class="signatoryLabelAdditional" ng-class="{required:!currentQuoteQto.preferredBillingCity}"
   translate>qrDetail.billingCity</p> <input type="text" class="signatoryInput" ng-model="currentQuoteQto.preferredBillingCity"
                                             ng-change="modifyBillingInformation()"
                                             maxlength="50"
                                             name="billingCity"
                                             ng-disabled="currentQuoteApproved() && currentQuoteQto.approvalLevel == null ||  billingCountryDisabled"
                                             required>
<p ng-show="additionalInformationForm.billingCity.$invalid && submitClicked" class="formError" style="clear: both; margin-left: 205px" translate>form.mandatory</p>

1 个答案:

答案 0 :(得分:0)

当您传递解析为true或false的参数时,Angular支持使用条件ng:

<p class="signatoryLabelAdditional" ng-class="{required:!currentQuoteQto.preferredBillingCity}"
   translate>qrDetail.billingCity</p> <input type="text" class="signatoryInput" ng-model="currentQuoteQto.preferredBillingCity"
                                             ng-change="modifyBillingInformation()"
                                             maxlength="50"
                                             name="billingCity"
                                             ng-disabled="currentQuoteApproved() && currentQuoteQto.approvalLevel == null ||  billingCountryDisabled"
                                             ng-required="your_radio_button_value_here">
<p ng-show="additionalInformationForm.billingCity.$invalid && submitClicked" class="formError" style="clear: both; margin-left: 205px" translate>form.mandatory</p>

请参阅此处的文档:https://docs.angularjs.org/api/ng/directive/ngRequired