Angular-2-Page-Slider
Angular-2-Page-Slider copied to clipboard
Cannot read property 'pageCountChange' of undefined
// 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
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.
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.
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?
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
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?