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

rootNavCtrl is undefined #126

Closed
longdw opened this issue Jul 17, 2017 · 3 comments
Closed

rootNavCtrl is undefined #126

longdw opened this issue Jul 17, 2017 · 3 comments

Comments

@longdw
Copy link

longdw commented Jul 17, 2017

there has three tabs, in the first and second tab, this.rootNavCtrl = navParams.get('rootNavCtrl'); this can work normally, but in the third tab this.rootNavCtrlis undefined.

<super-tabs *ngIf="menus" [config]="{ sideMenu: 'left' }" 
        toolbarColor="primary" toolbarBackground="slideTabColor" 
        indicatorColor="primary" (tabSelect)="onTabSelect($event)">
        <super-tab *ngFor="let item of menus" [root]="pageContent" [title]="item.name" [rootParams]="getParams(item)"></super-tab>
</super-tabs>

in pageContent, i got rootNavCtrl like this:

constructor(private params: NavParams) {
        super();
        this.rootNavCtrl = params.get('rootNavCtrl');
        console.log(' nav-->' + this.rootNavCtrl);
    }
@ihadeed
Copy link
Member

ihadeed commented Sep 4, 2017

Seems to be working fine in the example project. Can you verify if it still is an issue? and if it is somehow caused by your extended class?

@longdw
Copy link
Author

longdw commented Sep 7, 2017

@ihadeed yes, the question is still exist. I found the reason caused this question. When I delete [rootParams]="getParams(item)", it works fine.The getParams(...) method is:

getParams(item) {
        let params = {
            title: 'test'
        };
        return params;
    }

you can see this github example, glad to see your response, thank you very much.

@ihadeed
Copy link
Member

ihadeed commented Jan 25, 2018

So sorry for the late response @longdw

Seems like the issue is that you're using getParams function. When you use a function, Angular will keep calling that function to make sure the value didn't change. So it ends up updating the rootParams for that tab multiple times, and super-tabs only sets the value once. I just fixed that to make sure we always have rootNavParams :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants