question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Content projection into md-input-container must contain an md-input

See original GitHub issue

Bug, feature request, or proposal:

Bug/Feature

What is the expected behavior?

md-input-container validation should occur after content projection is applied

What is the current behavior?

The resulting content projection provides the md-input/mdInput, but the validation does not take this into account

What are the steps to reproduce?

Create a component similar to: <md-input-container> <ng-content></ng-content> </md-input-container> and pass an input to the component. No matter what you pass in, you always get the error

md-input-container must contain an md-input directive. Did you forget to add md-input to the native input or textarea element?

https://plnkr.co/edit/X2cKySR81BG51IbshX4m?p=preview

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

It makes it particularly hard to extend the functionality of md-input-container with this

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

Angular 4.0.0-beta.6 material 2.0.0-beta.1

Is there anything else we should know?

I was able to solve this with a directive selector =‘md-input-container’ and insert the desired content (validation messages) at runtime, but this is not nearly as clean and using content projection.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:3
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
edster23commented, Mar 27, 2017

@pgrm Here is what I am using until this is resolved. I have added more of our custom components to this selector and have a bit more code to work between them, but this is the jist of it.

https://plnkr.co/edit/WTVqPeWg63tBu0wOOk59?p=preview

0reactions
angular-automatic-lock-bot[bot]commented, Sep 7, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular - md-input-container must contain an mdInput directive?
I have installed npm install -g angular-cli, npm install --save @angular/material ,Imported the Angular Material NgModule in app.ts,added @ ...
Read more >
allow `MatFormFieldControl` to be content projected into `mat ...
Inability to use mat input with content projection. ... In console i have an error: mat-form-field must contain a MatFormFieldControl.
Read more >
Angular2: Error – md-input-container must contain an mdInput ...
I am using a using ASP.NET Core Anguar2 Starter Application. I am successful in upgrading the project to 2.4.9 but building the project...
Read more >
Use ng-content (content projection), ng-template ...
In this blog, I will define a use case where it makes sense to employ content projection using ng-content as well as ng-template...
Read more >
Angular Material Inputs - Javatpoint
The angular material input-container is a used to contains any <input> or <textarea> element as a child. It also supports error handling using...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found