I know this has been asked many times, but after reading similar problems I'm still unable to organize my code to fix this exception,
in my component I have this property that change dynamically based on a condition
public emailToValue: string
in my html
the user can manually add a new row and then I call a pipe to set the value assigned in the component
<ng-container matColumnDef="emailTo">
<mat-header-cell *matHeaderCellDef mat-sort-header>Email To</mat-header-cell>
<mat-cell *matCellDef="let userMarket">
{{ userMarket | formatEmailTo : emailToValue}}
<input type="text" matInput [value]="userMarket.emailTo">
</mat-cell>
</ng-container>
this is my pipe, if the email is null or undefined I set by default an email to be displayed in the new row
@Pipe({
name: 'formatEmailTo',
})
export class FormatEmailPipe implements PipeTransform {
public transform(userMarket: UserMarketDTO, email: string): void {
if (_.isNil(userMarket.emailTo)) {
userMarket.emailTo = email;
}
}
}
functionality is working but Im getting this exception every time that I create a new row
ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'value: undefined'. Current value: 'value: [email protected]'.
I would appreciate any help
thanks