角度ng重复错误显示

时间:2017-02-12 23:56:43

标签: javascript angularjs angularjs-ng-repeat

我在表单标签中有以下代码,我希望在复选框下面显示一些错误文本,但是目前我无法使用下面的当前设置。我在这里做错了什么?

售票/ competition_checkboxes.html

 Intent intent = new Intent(context, MediaActivity.class);
    RQS = (int) System.currentTimeMillis();

    PendingIntent pIntent = PendingIntent.getActivity(context, RQS, intent,
            PendingIntent.FLAG_UPDATE_CURRENT);

NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.notify(1, mBuilder.build());

页面上的当前输出是

The form before submission

The form after submission

如您所见,条款和条件复选框可以正确验证,但这是因为它不在ng-repeat中

条款和条件具有此代码

<div ng-repeat="compCbx in competitionCheckboxes track by $index">
    <input ng-attr-id="cc_comp_{{ $index }}" ng-model="compCbx.isChecked" name="cc_comp" ng-attr-label="cc_comp_label_{{ $index }}"
           type="checkbox" ng-required="compCbx.checkRequired" ng-checked="compCbx.isChecked" form-blur />
    <label ng-attr-id="cc_comp_label_{{ $index }}" ng-attr-for="cc_comp_{{ $index }}" class="fake-label">
        <i ng-attr-id="cc_comp_cbx_{{ $index }}"></i> <p ng-bind-html="compCbx.text | to_trusted"></p>
        <span class="error-msg error-tnc" ng-show="{{formName}}.cc_comp.$touched && {{formName}}.cc_comp.$error.required">
            You must agree to enter the competition
        </span>
    </label>
</div>

Form Blur指令

<input id="cc_tnc" ng-model="cc_tnc" label="cc_tnc_label" name="cc_tnc" type="checkbox" ng-required="cc_tnc != true" form-blur>
        <label id="cc_tnc_label" for="cc_tnc" class="fake-label">
            <i id="cc_tnc_cbx"></i> <p>I have read and agree to <a href="@Model.TermsUrl" target="_blank">terms and conditions</a></p>
            <span class="error-msg error-tnc" ng-show="{{ formName }}.cc_tnc.$touched && {{ formName }}.cc_tnc.$error.required">
                    You must agree to the Terms and Conditions to make a purchase
            </span>
        </label>
<ng-include src="'ticketing/competition_checkboxes.html'"></ng-include>

1 个答案:

答案 0 :(得分:1)

extern crate openssl; use openssl::rand::rand_bytes; fn main() { let mut a: [u8; 5] = [0,1,2,8,6]; match rand_bytes(&mut a) { Ok(_) => println!("Success"), Err(_) => println!("ERR"), } } 更改为ng-required="compCbx.checkRequired"

Jsfiddle working sample

我不知道它为什么起作用;)