Skip to content

tabs break @Viewchild #573

Closed
Closed

Description

@RoxKilly

Using a template variable within md-tab-group and trying to access it in the component with @Viewchild does not work.
My template

<md-tab-group>
<md-tab>
    <template md-tab-label>Tab Title</template>
    <template md-tab-content>
        <video #vidPlayer>
            <source src="http://localhost/vid.mp4" type="video/mp4">
        </video>   
    </template>
</md-tab>
</md-tab-group>

My component

@ViewChild('vidPlayer') player;
ngAfterViewInit(){console.log(this.player);}

undefined is logged to the console. If I move the <video> element out of <md-tab-group>, it gets correctly logged to the console.

Activity

  1. aminebizid commented on May 29, 2016

    @aminebizid

    I think i't better with @ContentChild
    Chears

  2. RoxKilly commented on May 29, 2016

    @RoxKilly
    Author

    Do I need to make any other change (besides switching decorator name @ViewChild to @ContentChild and importing ContentChild)? Now I get undefined logged to the console even if I move the <video> out of <md-tab-group>

  3. jelbourn commented on May 31, 2016

    @jelbourn
    Contributor

    @RoxKilly your initial example is correct in using @ViewChild and not @ContentChild. We'll look into it.

  4. added
    P2
    on May 31, 2016
  5. added this to the alpha.6 milestone on May 31, 2016
  6. added
    P3
    and removed
    P2
    on Jun 27, 2016
  7. modified the milestones: alpha.6, alpha.7 on Jun 27, 2016
  8. RoxKilly commented on Sep 2, 2016

    @RoxKilly
    Author

    @jelbourn I noticed that this issue has not be added to alpha.8. Just wanted to note that this has still not been resolved as of Angular 2 rc 5 and Material 2 alpha 7-4

    Open this plunker, go to AppComponent and take a look at the console.

  9. RoxKilly commented on Sep 3, 2016

    @RoxKilly
    Author

    Angular 2 rc.6 with ng-Material 2 alpha 8-1 still has this bug. Removing the <template> tag around the @ViewChild target gets the reference to work but of course breaks the tabs.

  10. fmoessle commented on Oct 7, 2016

    @fmoessle

    I have the same problem with angular 2.0.1.

  11. z639 commented on Oct 7, 2016

    @z639

    Me too, why is no one assigned to this ?
    Are people under the impression that is has been fixed ?

  12. modified the milestone: alpha.7 on Nov 1, 2016
  13. aecz commented on Nov 2, 2016

    @aecz

    Same issue on Angular 2.0.0 and Material 2.0.0-alpha.9-3.
    Spent one hour looking for this issue :( Ill switch to another theme for now. Better to wait until its out of alpha :)

  14. jelbourn commented on Nov 2, 2016

    @jelbourn
    Contributor

    This was fixed by #1645, which will be part of alpha.10

  15. angular-automatic-lock-bot commented on Sep 5, 2019

    @angular-automatic-lock-bot

    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.

  16. locked and limited conversation to collaborators on Sep 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions