Mat-hint and mat-error wrong behavior
Bug, feature request, or proposal:
Bug
What is the expected behavior?
Will expect see hint or error
What is the current behavior?
The behavior is strange: I try to build dynamic form by special config file. See https://angular-material2-issue-vysbqe.stackblitz.io/
-
If You uncomment block inside 1. mat-error without ngFor START.
The error in this block. You'll not see mat-error -
If You uncomment block inside 2. mat-error in ngFor START, you'll see strange behavior of mat-error. The error message will be inside the input field
-
If You uncomment block inside 3. mat-hint without ngFor START, everything will be good.
-
If You uncomment block inside 4. mat-hint in ngFor START, you'll see strange behavior of mat-hint. The error message will be inside the input field.
I have array of validation rules. I try to build dynamic validation section like below:
<ng-container *ngFor="let validator of input?.validators">
What are the steps to reproduce?
Providing a StackBlitz reproduction is the best way to share your issue.
StackBlitz starter: https://goo.gl/wwnhMV
How to reproduce it, I described earlier in the section What is the current behavior Works example: https://angular-material2-issue-vysbqe.stackblitz.io/
What is the use-case or motivation for changing an existing behavior?
I think it need for build dynamic reactive form with validation rules.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
I'm not sure this info help you. It easy reproduce in https://angular-material2-issue-vysbqe.stackblitz.io/ Angular: 5.2.0 Material: 5.2.4 OS: 10.13.1 TypeScript: 2.8.1 browsers all
Is there anything else we should know?
This works on my other projects without material library. Also, it works if I create custom div element with custom css.
I think the issue is just the use of <ng-container> to wrap <mat-error> in your example. That causes the error message to be content projected into the wrong slot. Instead just leave it off: https://stackblitz.com/edit/components-issue-4vs5v4?file=src/app/example-component.html
I've opened an issue on angular/angular about the content behavior being confusing with <ng-container> https://github.com/angular/angular/issues/37328
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.