在这里,我需要将 tab.staffMemberId 发送到服务并获取值并填充 matInput 值。当标签更改时,我需要将Tab.staffmemberId发送到服务
<mat-tab-group>
<mat-tab *ngFor="let tab of StaffMemberList; let index = index" [label]="tab.staffMemberId">
{{tab.id}}
<mat-grid-list cols="3" rowHeight="8:1">
<mat-grid-tile>
<mat-form-field class="full-width">
<input matInput placeholder="Position" >
</mat-form-field>
</mat-grid-tile>
</mat-grid-list>
Run Code Online (Sandbox Code Playgroud)
我有一个自定义验证器来检查重新输入确认
import { AbstractControl } from '@angular/forms';
export function RetypeConfirm(confirmpassword: string) {
return (control: AbstractControl): { [key: string]: boolean } | null => {
if (control.value !== confirmpassword) {
return { 'mismatch': true };
}
return null;
};
}
Run Code Online (Sandbox Code Playgroud)
我的打字稿文件
import { FormBuilder, Validators, FormGroup } from '@angular/forms';
import { RetypeConfirm } from 'app/validators/retype-confirm.validator';
passwordChangeForm: FormGroup;
constructor(private fb: FormBuilder){
this.passwordChangeForm = this.fb.group({
newPassword: ["", [Validators.required, Validators.pattern(RegEx.STRONG_PASSWORD)]],
confirmpassword: ["", [Validators.required, RetypeConfirm(***I want to pass passwordChangeForm.controls['newPassword'].value here**** )]]
});
}
Run Code Online (Sandbox Code Playgroud)
我需要传递this.passwordChangeForm.controls['newPassword'].value …