Closed
Description
Bug, feature request, or proposal:
Proposal
Currently
If a user wishes to surround MdErrors
with a structural directive, the errors will no longer be projected inside the mat-input-subscript-wrapper
.
<!-- This will not work -->
<md-form-field>
<input mdInput>
<ng-container *ngFor="let error of allErrors">
<md-error *ngIf="showError(error)">{{error.message}}</md-error>
</ng-container>
</md-form-field>
This is (sort of) expected behavior if you know that content projection works only on top level elements. Still, if you want to conditionally render your errors with ngFor
and ngIf
you have to use one of the workarounds (listed under Motivation).
Proposed
<!-- This could work -->
<md-form-field>
<input mdInput>
<md-error-container *ngFor="let error of allErrors">
<md-error *ngIf="showError(error)">{{error.message}}</md-error>
</md-error-container>
</md-form-field>
<!-- form-field.html -->
...
<div *ngSwitchCase="'error'" [@transitionMessages]="_subscriptAnimationState">
<ng-content select="md-error, md-error-container"></ng-content>
</div>
Reproduction
This is an example showing how it could work
http://plnkr.co/edit/6c6Zi6m1dNAnF10smWPK?p=preview
Motivation
Couple of issues bringing this up
Workarounds: