New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When using @ViewChild element.nativeElement is undefined #3922
Comments
As a workaround for now, you can define Child like this
For anyone wondering. |
yeah I saw that thing when I was debugging, also there is one more option is to use |
This is working as expected. When using |
@jelbourn why it is expected?
Some more details plz |
@kuncevic this should help |
I also have this problem. I don't understand why you say this is OK - if it works with a button without the md-radio-button, surely it should work for one with it? How can I get around this problem? |
@gouldina Please refer to the link that @willshowell posted above. Basically, just do The reason is that md-radio-button is an angular component (which itself is a directive) and ViewChild returns the whole component if you do not specify the read option |
Thanks HunderlinK. I'll try that. |
To add on to @Nikki1993's answer (which works absolutely awesome), Angular Material 6 already has an interface you can use to type it:
|
Thanks @HunderlineK |
down to 209, and this problem still exists. |
@raj2033 did you try any of solutions above? |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug, feature request, or proposal:
Bug
What is the expected behavior?
@ViewChild
element.nativeElement
has valueWhat is the current behavior?
@ViewChild
element.nativeElement
isundefined
What are the steps to reproduce?
http://plnkr.co/edit/gSEsELlTAbrqvOOduSdr?p=preview
What is the use-case or motivation for changing an existing behavior?
Need to access to an element with
@ViewChild
Which versions of Angular, Material, OS, browsers are affected?
Angular 4.0.1
Material beta.2
All browsers
Is there anything else we should know?
If you take out the
md-raised-button
from the button thenthis.button.nativeElement
will work.The text was updated successfully, but these errors were encountered: