Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
581 views
in Technique[技术] by (71.8m points)

angular - 获取表单提交时所有p复选框的状态(Angular PrimeNG)(Get status of all p-checkbox on form submit (Angular PrimeNG))

I have multiple checkbox in my form beside every field, checkbox data will not saved.

(我的表单中每个字段旁边都有多个复选框,复选框数据将不会保存。)

I have to figure out all checkboxes are selected before form submitting.

(我必须弄清楚在提交表单之前所有复选框都已选中。)

If all checkbox selected I will get true otherwise false.

(如果选中所有复选框,我将得到true,否则得到false。)

I need to do in dynamic way as I have huge amount of field in my form.

(我需要以动态方式进行操作,因为我的表单中包含大量字段。)

Given some portion of my html code...

(给定我的html代码的一部分...)

                            <div class="ui-g-12 ui-md-12">
                                <div class="ui-g-12 ui-md-11">
                                    <span class="md-inputfield">
                                        <input type="text" pInputText 
                                    formControlName="sequenceOfTotal">
                                        <label>Sequence of Total(27)</label>
                                    </span>
                                </div>
                                <div class="ui-g-12 ui-md-1">
                                    <span class="md-inputfield">
                                        <p-checkbox binary="true">
                                        </p-checkbox>
                                    </span>
                                </div>
                            </div>
  ask by md. erfan translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I think you are looking for cross-field validation.

(我认为您正在寻找跨领域验证。)

https://medium.com/@realTomaszKula/angular-cross-field-validation-d94e0d063b61 https://angular.io/guide/form-validation#cross-field-validation

(https://medium.com/@realTomaszKula/angular-cross-field-validation-d94e0d063b61 https://angular.io/guide/form-validation#cross-field-validation)

You need to create a form field for your checkboxes too

(您还需要为复选框创建一个表单字段)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...