components icon indicating copy to clipboard operation
components copied to clipboard

md-input-container not recognizing mdInput

Open jasonhodges opened this issue 9 years ago • 17 comments

Bug, feature request, or proposal:

Bug

What is the expected behavior?

md-input-container recognizes the child input element

What is the current behavior?

error is being thrown on load, stating md-input-container must contain an md-input directive

What are the steps to reproduce?

Providing a Plunker (or similar) is the best way to get the team to see your issue. Plunker template: http://plnkr.co/edit/o077B6uEiiIgkC0S06dd

I have tested this in Plunker with the provided template above and was successful at adding an input. Doing so the exact same way in our application produces the md-input-container must contain an md-input directive error on one specific component. Implementation in other parts of the application seem to be working fine. Could there be some issue with the order in which the library is being loaded in relation to the components utilizing md-input?

Unfortunately I am unable to post our code anywhere. I have tried all the different variations of the directive (md-input, mdInput, etc)

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

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

Is there anything else we should know?

The following are the versions I am running: "@angular/common": "2.4.4", "@angular/compiler": "2.4.4", "@angular/compiler-cli": "2.4.4", "@angular/core": "^2.4.4", "@angular/forms": "2.4.4", "@angular/http": "2.4.4", "@angular/material": "^2.0.0-beta.1", "@angular/platform-browser": "2.4.4", "@angular/platform-browser-dynamic": "2.4.4", "@angular/router": "3.4.4"

jasonhodges avatar Jan 23 '17 15:01 jasonhodges

@jasonhodges, i think they are tracking this and the fix is in next release (maybe?) just use <input md-input> for now

https://github.com/angular/material2/issues/2529

wyers avatar Jan 23 '17 17:01 wyers

I have tried all the different variations of the directive (md-input, mdInput, etc)

@wyers As I mentioned, I have tried this

jasonhodges avatar Jan 23 '17 17:01 jasonhodges

@jasonhodges Since you are not able to share a Plunker or some code, can you try sharing some similar code here?

e.g

<md-input-container>
  <input mdInput placeholder="Test">
</md-input-container>

devversion avatar Jan 24 '17 13:01 devversion

@DevVersion This is how I have it implemented:

<md-list-item>
    <md-input-container>
        <input md-input
            placeholder="Description"
            type="text"
            name="description"
            [formControl]="formGroup.get('description')"
            [ngModel]="model.description"
            (blur)="persistChange({description: $event.target.value})">
     </md-input-container>
</md-list-item>

jasonhodges avatar Jan 24 '17 15:01 jasonhodges

Thanks. While looking at it, it looks valid as for the beta.1 release.

If you can share the exact error from the browser console, that would be perfect!

devversion avatar Jan 24 '17 15:01 devversion

Thanks @DevVersion , here you go md-input_error

jasonhodges avatar Jan 24 '17 15:01 jasonhodges

Hm, since everything works in the Plunker template I'm thinking about something in your build process that might modify the HTML attributes? (e.g html-min)

Is your application being compiled with such tools?

devversion avatar Jan 24 '17 15:01 devversion

@DevVersion I apologize, not sure why this weird instance happened but after shutting everything down, and launching a fresh build the issue is no longer present. I suspect some leftovers were being served. Thanks for your quick responses

jasonhodges avatar Jan 24 '17 15:01 jasonhodges

@jasonhodges No problem. Glad everything works now :)

devversion avatar Jan 24 '17 15:01 devversion

inline template:13:32 caused by: md-input-container must contain an mdInput directive. Did you forget to add mdInput to the native input or textarea element? ; Zone: angular ; Task: Promise.then ; Value: e undefined app.moudle.ts import { MaterialModule,MdInputModule } from '@angular/material';

imports: [ FormsModule, routing, ExportAllService, CustomFormsModule, ReactiveFormsModule, PaginationModule.forRoot(), AccordionModule.forRoot(), ToastModule.forRoot(), ModalModule.forRoot(), MaterialModule.forRoot(), MdInputModule, UniversalModule, ],

ponmani avatar Apr 04 '17 11:04 ponmani

Doesn't work for me

ponmani avatar Apr 04 '17 11:04 ponmani

@ponmani On the latest release of Angular Material 2 (2.0.0-beta.2), it has changed to mdInput.

<md-input-container>
  <input mdInput placeholder="Text here">
</md-input-container>

EdricChan03 avatar Apr 04 '17 11:04 EdricChan03

@Chan4077 You have mentioned code used. But i am using .Net core app.

ponmani avatar Apr 05 '17 13:04 ponmani

If i anything write in type script of this piece of code

<md-input-container> <input mdInput placeholder="Text here"> </md-input-container>

ponmani avatar Apr 05 '17 13:04 ponmani

@Chan4077 Any update for this.

ponmani avatar Apr 07 '17 04:04 ponmani

@ponmani Maybe try importing just MaterialModule?

EdricChan03 avatar Apr 07 '17 09:04 EdricChan03

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.