<div class="owl-carousel owl-theme">
<div class="item">
<h4>1</h4>
</div>
<div class="item">
<h4>2</h4>
</div>
<div class="item">
<h4>3</h4>
</div>
<div class="item">
<h4>4</h4>
</div>
<div class="item">
<h4>5</h4>
</div>
</div>
ngAfterViewInit() {
$(document).ready(function () {
$('.owl-carousel').owlCarousel({
loop: true,
margin: 10,
responsiveClass: true,
autoWidth: false,
navText: ["Предыдущий", "Следующий"],
responsive: {
0: {
items: 1,
nav: true
},
600: {
items: 3,
nav: false
},
1000: {
items: 5,
nav: true,
loop: false,
margin: 20
}
}
});
});
}
<div class="owl-carousel owl-theme">
<div class="item" *ngFor="let t of test">
<h4>{{t.name}}</h4>
</div>
</div>
import {Directive, Input} from '@angular/core';
@Directive({
selector: '[scroll]'
})
export class ScrollDirective {
constructor() {
}
@Input('scroll')
set appScroll(isReady: boolean) {
if (isReady)
this.ngForCallback();
}
ngForCallback() {
$('.owl-carousel').owlCarousel({
loop: true,
margin: 10,
responsiveClass: true,
autoWidth: false,
navText: ["Предыдущий", "Следующий"],
responsive: {
0: {
items: 1,
nav: true
},
600: {
items: 3,
nav: false
},
1000: {
items: 5,
nav: true,
loop: false,
margin: 20
}
}
});
console.log('run');
}
}
.....
<div class="owl-carousel owl-theme">
<div class="item" *ngFor="let t of test; let l=last" [scroll]="l ? true : false">
<h4>{{t?.name}}</h4>
</div>
</div>
.....
$('.owl-carousel').owlCarousel({
....
}))
<li *ngFor="let item in Items; let last = last">
...
<span *ngIf="last">{{ngForCallback()}}</span>
</li>
public ngForCallback() {
...
}