如何推动后关闭在垫子对话框角度



我想根据我拥有的数据量迭代我的formarray,例如:我的序列号是3,所以它会把我的数组推到3行。如何做到这一点?到目前为止,这就是我编写的代码。

https://stackblitz.com/edit/mat-dialog-example-qjwsd5?

所以你的问题还不清楚,我为stackblitz感到高兴,但我需要你希望输出的屏幕截图,无论如何,这是我所理解的版本,希望它能有所帮助!

ts

import { Component, Inject } from '@angular/core';
import {
VERSION,
MatDialogRef,
MatDialog,
MatSnackBar,
MAT_DIALOG_DATA,
} from '@angular/material';
import { ConfirmationDialog } from './confirmation-dialog.component';
import { AlertDialogComponent } from './alert-dialog/alert-dialog.component';
import { FormGroup } from '@angular/forms';
import { FormBuilder } from '@angular/forms';
import { OnInit } from '@angular/core/src/metadata';
import { FormArray } from '@angular/forms';
import { async } from '@angular/core/testing/src/async';
@Component({
selector: 'material-app',
templateUrl: 'app.component.html',
})
export class AppComponent implements OnInit {
version = VERSION;
value = '';
fg: FormGroup;
showButton = true;
constructor(
private dialog: MatDialog,
private snackBar: MatSnackBar,
private fb: FormBuilder
) {
this.fg = this.fb.group({
name: [],
lastname: [],
Info: this.fb.array([this.item()]),
});
}
ngOnInit() {
this.item();
}
item(): FormGroup {
return this.fb.group({
qty: [],
total: [],
});
}
get Info(): FormArray {
return this.fg.get('Info') as FormArray;
}
addRow() {
return this.Info.push(this.item());
}
openAlertDialog(index: number) {
const dialogRef = this.dialog.open(AlertDialogComponent, {});
dialogRef.afterClosed().subscribe((result) => {
for (let i = 0; i < result.qty; i++) {
this.Info.push(this.item());
}
for (let i = 0; i <= result.qty; i++) {
this.Info.at(i).patchValue({ qty: result.qty });
}
});
}
OpenSemame() {
const dialogRef = this.dialog.open(AlertDialogComponent, {});
}
}

分叉堆叠式

最新更新