mujtaba01 / ngx-owl-carousel

An angular2 (4) wrapper for jquery owl-carousel library with dynamic carousel item change detection
MIT License
70 stars 25 forks source link

Not working correctly on lazy loaded module #25

Open plastikaweb opened 7 years ago

plastikaweb commented 7 years ago

Hi,

I've got exactly the same code in my main app component, and in a lazy loaded component.

<div (click)="change()">click</div>
<owl-carousel #owlElement
              [options]="carouselOptions"
              [items]="images"
              [carouselClasses]="['owl-theme', 'sliding']">
  <div class="item deal-slide" *ngFor="let image of images;let i = index">

    <div class="coupons-div" style="cursor:pointer;">
      <img class="deals-image" src="{{image}}"/><br/>
    </div>
  </div>
</owl-carousel>
export class AppComponent {
  images = [
    'img1.jpg',
    'img2.jpg'
  ];

  carouselOptions: any = {
    nav: true,
    dots: false,
    loop: true,
    items: 2
  };

  change() {
    this.images = [
     'img3.jpg',
     'img4.jpg
    ];
  }

I've got in both the main.module.ts and the lazy.module.ts imported the OwlModule module. I don't know if I've doing something wrong or it is a bug.

Any ideas? Thanks in advance!

ghost commented 6 years ago

I have the same probleme.

I can see with the inspector that ng carousel markup has been added in the html.

But no carousel visible.