Unable to resolve error in ng build --prod after successful execution of ng serve: Error - Property 'element' does not exist on type 'Element'.
https://i.sstatic.net/l3KX4.png
Edit-depart.html
<form #employeeForm="ngForm" (ngSubmit)="onSubmit(employeeForm)" novalidate>
<input type="hidden" name="id" [(ngModel)]="data.element.id" />
<h2 mat-dialog-title>Modifier Courrier Depart</h2>
<mat-dialog-content class="mat-typography">
<mat-card>
<mat-card-header fxLayoutAlign="center">
<mat-card-subtitle><h2>Information</h2></mat-card-subtitle>
</mat-card-header>
<table cellspacing="2" class="w-100">
<tr>
<td>
<mat-form-field class="w-100" appearance="outline" >
<mat-select placeholder="Type Contrat" name="type" [(ngModel)]="data.element.type">
<mat-option *ngFor="let contrat of contrats" [value]="contrat.value" >
{{contrat.viewValue}}
</mat-option>
</mat-select>
</mat-form-field>
</td>
<td>
<mat-form-field class="w-100" appearance="outline">
<input matInput placeholder="Destinataire" name="destinataire" [(ngModel)]="data.element.destinataire">
</mat-form-field>
</td>
</tr>
</table>
</mat-dialog-content>
<mat-dialog-actions align="end">
<button mat-raised-button color="primary" type="submit" [disabled]="!employeeForm.valid" [mat-dialog-close]>Update</button>
</mat-dialog-actions>
</form>
departs.component.ts
editDepart(element: Element) {
// this.selectedEmployee = element;
let dialogRef = this.dialog.open(EditDepart, { disableClose: true,data: { element } });
dialogRef.afterClosed().subscribe(result => {
this.refreshEmployeeList();
})
}
export interface Element {
id: any;
type: any;
destinataire: any;
}
Edit-depart
export class EditDepart {
constructor( private _employeeService: EmployeeService,
public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: Element) {
}
@Output() submit: EventEmitter<any> = new EventEmitter();
onSubmit(form: NgForm) {
if (form.value.id == null) {
this._employeeService.postEmployee(form.value).subscribe((res) => {
this._employeeService.getEmployeeList().subscribe((res) => {
this.submit.next(res as Employee[]);
});
// M.toast({ html: "Saved successfully.", classes: "rounded" });
});
}
else {
this._employeeService.putEmployee(form.value).subscribe((res) => {
this._employeeService.getEmployeeList().subscribe((res) => {
this.submit.next(res as Employee[]);
//this.employees = employees;
});
});
}
}
}