Components: feat: allow `MatFormFieldControl` to be content projected into `mat-form-field` using `ng-content`

Created on 16 Jan 2018  路  23Comments  路  Source: angular/components

Bug, feature request, or proposal:

Placeholder on input not floating when projected from ng-content.

What is the expected behavior?

Placeholder must floating, when input has some value.

What is the current behavior?

Placeholder looks like standard html placeholder, not like material placeholder.

What are the steps to reproduce?

StackBlitz: https://stackblitz.com/edit/angular-material2-issue-jekywv

What is the use-case or motivation for changing an existing behavior?

Inability to use mat input with content projection.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

latest

Is there anything else we should know?

In console i have an error: mat-form-field must contain a MatFormFieldControl.

P3 feature needs discussion

Most helpful comment

Have the same issue. This feature will extremely help me to reduce boilerplate html. @mmalerba, please, fix it! Thx

All 23 comments

FYI it's not just the placeholder that has issues, this is completely unsupported right now, hence the errors

Have the same issue. This feature will extremely help me to reduce boilerplate html. @mmalerba, please, fix it! Thx

News?

I ended up using material-design-lite as a temporary solution, hope this gets resolved soon.

Are there any related issues to this one? This seems like a very glaring oversight that should've been fixed by now.

ERROR Error: mat-form-field must contain a MatFormFieldControl. same error, all modules working well, except this.

Hi, any comments on the status of this issue?

Mh.. this complicates things. Not using ng-content but ngTemplateOutlet, but that the same story I guess.

There has a dirty method is setting the matformFieldControl in the custom field component.

StackBlitz: https://stackblitz.com/edit/angular-material2-issue-rewh7v?file=app/field.component.ts

This is a rather glaring limitation. Hopefully it gets addressed soon.

I only get this error when I add the basic native select, but other work fine.