i have this console error in my angular6 project : Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'flag: '. Current value: 'flag: null'.
this is the code in the ts component child
@Input() flag: any;
this is the code in the html component child
<div *ngIf="flag !== 'ABBONAMENTO_MDA'">
<div class="form-group col-lg-3 col-md-3">
// something else
</div>
</div>
<div *ngIf="flag === 'ABBONAMENTO_MDA'">
<div class="form-group col-lg-3 col-md-3">
// something else
</div>
this is the code in the component father
<app-repertorio
[flag]="eventoSelezionato" // here i intercept the state of flagMda
</app-repertorio>
Initializing the flag variable with some initial value should resolve this problem. And this also allows to have an initial state for your component to fallback to just in case the flag value is undefined through the input
eventoSelezionato.@Input() flag: string = 'INITIAL_VALUE';