Closed elyas145 closed 1 year ago
Hi @elyas145,
I've never seen that error in matSelect, but it seems to have happened to others too: https://github.com/angular/components/issues/14793
Thank you for the prompt response. I was able to solve the issue by having the surrounding component implement AfterViewChecked, and calling detectChanges() on ChangeDetectorRef.
Someone commented that their problem was solved by upgrading to Angular 10, this did not solve my problem. (Angular 10.0.8, Ivy enabled, Material 10.1.3)
Closed due to inactivity
I have a component which houses a mat-form-field, with a mat-select element. this element has mat-option tags with text that needs translation.
<mat-option value="intranet_virt_absb_e"> {{"infozone_search.branch_abbr.absb" | translate: locale.language}}</mat-option>
where locale is
@Inject(L10N_LOCALE) public locale: L10nLocale
The initial translation works fine, however, when I switch languages using the same method as the stackBlitz example, I get a ExpressionChangedAfterItHasBeenCheckedError. The previous and current values in the error pertain to the current selection in the mat-select field. if the option is selected, then the locale is set to fr via the language button, the error message would show previous value "null:
for some reason, Angular is doing the checking before the translation is finished. I tried this with the directive, as well as pipes. here is the full mat-select component. the rest of the application translates without error, and without looking at the console, the app behaves as expected (the selected value in the mat-select field is being translated back and forth).
`
`
I also tried adding the l10nTranslate directive to both the mat-form-field tag, and the mat-select tag. none worked.
any feedback or comments appreciated. Thank you!