I've imported owl-carousel libraries into my Angular2 CLI project, which displays correctly if I have:
<div class="owl-carousel owl-theme" #carousel >
<div>item</div>
<div>item</div>
<div>item</div>
<div>item</div>
</div>
but I need the data for the carousel to load asynchronously. So in my component's typescript I've updated to:
...
this.getData().subscribe(
d => {
this.data = <Results>d;
},
error => {
console.log(error);
});
...
Then in my html for the component I now have:
<div class="owl-carousel owl-theme" #carousel >
<div *ngFor="let item of data.items">
<h1>Item name</h1>
{{item.name}}
</div>
</div>
However it doesn't display correctly. The data is loaded but the carousel doesn't set itself up properly. I've experimented with calling the element's owlCarousel() after the data has loaded but still didn't fix it.
I'm not sure what I'm doing wrong, anyone know how to fix this?