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

Cannot read property 'pageCountChange' of undefined #1

Open
rupakshukla opened this issue Jul 21, 2016 · 5 comments
Open

Cannot read property 'pageCountChange' of undefined #1

rupakshukla opened this issue Jul 21, 2016 · 5 comments

Comments

@rupakshukla
Copy link

// Get the page renderer loop and keep its size up to date
@ContentChild(KBPagesRendererDirective) renderer : KBPagesRendererDirective;
ngOnInit(){
this.renderer.pageCountChange.subscribe((count)=>{
this.pageCountChange.emit(count);
});

    this.Resize();
    this.renderer.Resize(this.pageWidth, this.pageHeight);
    window.addEventListener("resize", ()=>{
        this.Resize();
        this.renderer.Resize(this.pageWidth, this.pageHeight);
        this.pageSizeChange.emit([this.pageWidth, this.pageHeight]);
    });
}

It is giving error Cannot read property 'pageCountChange' of undefined which seems renderer is not getting defined, what exactly is not working in my case. Which is defined in this @ContentChild(KBPagesRendererDirective) renderer : KBPagesRendererDirective;

Angular Version - 2.0.0-rc.1

@KeatonTech
Copy link
Owner

Does your template have a *kbPages="let page of pages" directive in it?

I should add an extra check, instead of just assuming it exists. I do in some other places but apparently missed ngOnInit. Will fix.

@rupakshukla
Copy link
Author

Yes i have this in my template *kbPages="let page of pages"

still it is not working.

Only difference in our case is that we are not bootstraping this component in same component.
I have a app component in which i import this slider component and i bootstrap the app component.

@KeatonTech
Copy link
Owner

Yeah, that is the normal use case (See /examples/hero/app.ts). Are you importing both KBPagesRendererDirective and KBPageSliderComponent into your app component as directives? Or, I guess more broadly, are there any errors in the web inspector?

@rupakshukla
Copy link
Author

yes, i am importing KBPagesRendererDirective and KBPageSliderComponent in my component as directives. and have also followed your example ( /examples/hero/app.ts). But Still getting the error

Cannot read property 'pageCountChange' of undefined

@KeatonTech
Copy link
Owner

Hmm, that is very odd. Is there anything you've done differently from the example that I could test to see if I can reproduce the error?

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