-
Notifications
You must be signed in to change notification settings - Fork 6.8k
<mat-error> not usable when instantiated inside <ng-template> #8097
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
mat-error
not usable when instantiated inside ng-template
Try this: <ng-template ngProjectAs="mat-error" [ngTemplateOutlet]="errTempl"
[ngOutletContext]="{ $implicit: theForm.controls['platform'] }"></ng-template> |
@julianobrasil I tried that, now the error message in the template is not displayed at all. See the updated stackblitz https://stackblitz.com/edit/angular-v6nvbn |
I really don't know whether this is a problem with angular or with material or with my undertanding of how some stuff works. This is similar to this other closed-without-complete-solution issue #6625 It starts working if you use an empty |
@julianobrasil thanks for the effort, I will use this workaround for now I guess. So do we just let this issue be and wait for it to get resolved by the way? |
@jelbourn, do you think this could be a material issue? It's similar to this other: #6625. By that time it was closed just because the original problem seemed to be solved. But there were cases without a solution in that issue. The most accepted theory was about an angular issue. cc: @rafaelss95 |
This is the expected behavior of Angular. |
@jelbourn Having said all that, is it still ok to do what I have done? Meaning - to create an |
If that works then it should be fine |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Uh oh!
There was an error while loading. Please reload this page.
Bug, feature request, or proposal:
Bug
What is the expected behavior?
It should be possible to use an
ng-template
withmat-error
inside it to create a reusable error display template.What is the current behavior?
When
mat-error
is included as part of anng-template
it is not rendered correctly.What are the steps to reproduce?
StackBlitz starter (using latest
npm
release): https://stackblitz.com/edit/angular-jpmbveNote how the
mat-error
element is instantiated inside theng-template
- doing it this way causes themat-error
text to be displayed incorrectly.What is the use-case or motivation for changing an existing behavior?
The use case is having a reusable error display template that can be attached to different fields with the same error logic.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular: 4.4.6
Angular animations: 4.4.6
Typescript: 2.5.3
Browser: Chrome 62.0.3202.75 (Official Build) (64-bit)
Is there anything else we should know?
The text was updated successfully, but these errors were encountered: