components icon indicating copy to clipboard operation
components copied to clipboard

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

Open rodaz opened this issue 8 years ago • 23 comments

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.

rodaz avatar Jan 16 '18 08:01 rodaz

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

mmalerba avatar Jan 16 '18 23:01 mmalerba

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

Ilya1vanov avatar Feb 25 '18 21:02 Ilya1vanov

News?

guilnorth avatar Mar 13 '18 00:03 guilnorth

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

papakojo avatar Apr 06 '18 21:04 papakojo

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

natepaxton avatar Apr 30 '18 13:04 natepaxton

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

winstonchavez avatar Jun 08 '18 17:06 winstonchavez

Hi, any comments on the status of this issue?

ianchi avatar Jun 26 '18 00:06 ianchi

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

fxck avatar Aug 23 '18 17:08 fxck

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

qwe852147 avatar Sep 14 '18 07:09 qwe852147

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

fatal-zio avatar Oct 23 '18 20:10 fatal-zio

This worked for me:

https://stackoverflow.com/questions/50574642/angular-material-mat-form-field-custom-component-matsuffix-in-ng-content

brampeirs avatar Oct 25 '18 14:10 brampeirs

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