我有这段代码:
this.form = fb.group({
username: ['', Validators.compose([Validators.required])],
fullName: ['', Validators.compose([Validators.required])],
password: ['', Validators.compose([Validators.required])],
confirmPassword: ['', Validators.required],
}, {validator: matchingPasswords('password', 'confirmPassword')});
matchingPasswords:
export function matchingPasswords(passwordKey: string, passwordConfirmationKey: string) {
return (group: FormGroup) => {
let password = group.controls[passwordKey];
let passwordConfirmation = group.controls[passwordConfirmationKey];
if (password.value !== passwordConfirmation.value) {
return passwordConfirmation.setErrors({mismatchedPasswords: true})
}
}
}
HTML:
<div class="form-group">
<input [formControl]="confirmPassword" class="form-control checking-field" type="password">
<span class="help-block text-danger" *ngIf="form.get('password').touched && form.get('password').hasError('required')">
</div>
<div class="form-group">
<input class="custom-control-input checkbox-main" type="checkbox" [(ngModel)]="policyButtonValue" [ngModelOptions]="{standalone: true}" ngDefaultControl>
<span class="custom-control-indicator"></span>
</div>
这是功能性的,并且运行良好,但我有一个特殊的用例场景应该修复。
答案 0 :(得分:4)
您需要一个<tr>
<td align="center" style="width: 1cm;">
<asp:Label ID="lblIndex" runat="server" Text='<%# Container.DataItemIndex + 1 %>'
Font-Bold="true" />.
<div <%# ((Container.DataItemIndex + 1) % 18 == 0) ? "class='page-break'": "" %>>
</div>
</td>
</tr>
<style type="text/css" media="print">
@page
{
size: auto;
margin: 1cm;
}
.page-break
{
float:none;
display: block;
page-break-before: always;
page-break-after: avoid;
clear: both !important;
}
</style>
块:
else