0

I am trying to go to a specific position of ngx-owl-carousel-o, after following the below tutorial from the tips section.

https://www.npmjs.com/package/ngx-owl-carousel-o#tips

Please note this is: owl-carousel-o not owl-carousel library

However, the the error I am getting is that the template reference on the owl-carousel-o tag is undefined when trying to call owlCar.to(): enter image description here

Tutorial from docs:

enter image description here

I have also tried printing the view child of the reference in the Typescript file but this is also returning undefined!

hhww59
  • 51
  • 9

2 Answers2

0

It seems like you didn't imported CarouselModule into module that declares component using <owl-carousel-o... >


import { CarouselModule } from 'ngx-owl-carousel-o';
@NgModule({
  imports: [ CarouselModule ],
  declarations: [ CarouselHolderComponent ]
})
export class SomeModule { }
0

I have found the solution to my question for anyone else who comes across this issue! Adding to the answer from Vitali, the CarouselModule had already been imported, which was not the issue.

So the solution I found relates to the below issue of template references being killed if they are within a ngIf* directive.

Angular 2 @ViewChild annotation returns undefined

Template references also become undefined within other Angular directives such as ng-template! So please keep note of this.

I hope this helped and Thank you Vitali for your help!

hhww59
  • 51
  • 9