Skip to content
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

Upgrade deprecated Query implementation to ContentChildren #850

Closed
mko opened this issue Sep 2, 2016 · 2 comments
Closed

Upgrade deprecated Query implementation to ContentChildren #850

mko opened this issue Sep 2, 2016 · 2 comments
Assignees
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@mko
Copy link

mko commented Sep 2, 2016

The deprecated Query and ViewQuery annotations have been replaced by ContentChildren and ViewChildren respectively. The resultant implementation is slightly different.

Old Query implementation:

    constructor(protected el: ElementRef,@Query(TabPanel) tabPanels: QueryList<TabPanel>) {
        tabPanels.changes.subscribe(_ => {
            this.tabs = tabPanels.toArray();
            let selectedTab: TabPanel = this.findSelectedTab();
            if(!selectedTab && this.tabs.length) {
                this.tabs[0].selected = true;
            }
        });
    }

New ContentChildren implementation:

    @ContentChildren(TabPanel) tabPanels: QueryList<TabPanel>;
    constructor(protected el: ElementRef) {
        this.tabPanels.changes.subscribe(_ => {
            this.tabs = this.tabPanels.toArray();
            let selectedTab: TabPanel = this.findSelectedTab();
            if(!selectedTab && this.tabs.length) {
                this.tabs[0].selected = true;
            }
        });
    }

And the imports change from Query to ContentChildren.

@mko
Copy link
Author

mko commented Sep 2, 2016

Note: This is for RC6 compatibility.

@cagataycivici cagataycivici added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label Sep 5, 2016
@cagataycivici cagataycivici added this to the 1.0.0-beta.15 milestone Sep 5, 2016
@cagataycivici cagataycivici self-assigned this Sep 5, 2016
@cagataycivici
Copy link
Member

Doing this at constructor fails though with undefined at this.tabPanels, so using afterContentInit as doc suggests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
Development

No branches or pull requests

2 participants