我有一个带有垫芯片列表的垫形式。表格位于草稿对话框中。 当我关闭对话框时,仅发送芯片列表中的最后一个元素,但我需要所有元素。
这是我的代码:
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
import numpy as np
@ticker.FuncFormatter
def major_formatter(x, pos):
label = str(-x) if x < 0 else str(x)
return label
y = np.linspace(-3000,-1000,2001)
fig, ax = plt.subplots()
ax.plot(y)
ax.yaxis.set_major_formatter(major_formatter)
plt.show()
我的对话框形式:
let dialogRef = this.dialog.open(DialogForm, {
width: '60vw',
data: { id : data.id }
});
dialogRef.afterClosed().subscribe(cars => {
if (cars!= null) {
console.log(cars ); // I only get the last car
}
});
我的模板
constructor(public dialogRef: MatDialogRef<DialogForm>, @Inject(MAT_DIALOG_DATA) public data: any, public formBuilder: FormBuilder) { }
// Initialize with the cars from DB
this.carService.getCars(12)
.subscribe(cars=> {
this.cars= <Car[]>cars;
});
this.carForm = new FormGroup({
id: new FormControl(this.data.id),
cars: new FormControl(this.cars, {
validators: Validators.required
})
}, { updateOn: 'change' });