Run yarn add ngx-owl-carousel-o or npm install ngx-owl-carousel-o or ng add ngx-owl-carousel-o.
Add styles (one of these variants).
src/styles.sass or src/styles.scss:
@import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel';
@import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';
Import RoutingModule and Routes into AppModule unless they are imported.
Import BrowserAnimationsModule into AppModule unless it is imported.
Import CarouselModule into a module which declares a component intended to have a carousel.
import { CarouselModule } from 'ngx-owl-carousel-o';
@NgModule({
imports: [ CarouselModule ],
declarations: [ CarouselHolderComponent ]
})
export class SomeModule { }
Add to needed component customOptions or named in different way object with options for the carousel:
import { OwlOptions } from 'ngx-owl-carousel-o';
@Component({
selector: '....',
templateUrl: 'carousel-holder.component.html'
})
export class CarouselHolderComponent {
customOptions: OwlOptions = {
loop: true,
mouseDrag: false,
touchDrag: false,
pullDrag: false,
dots: false,
navSpeed: 700,
navText: ['', ''],
responsive: {
0: {
items: 1
},
400: {
items: 2
},
740: {
items: 3
},
940: {
items: 4
}
},
nav: true
}
}
Add html-markup to the template of the component (in this case, add it to carousel-holder.component.html):
<div>Some tags before</div>
<owl-carousel-o [options]="customOptions">
<ng-template carouselSlide>Slide 1</ng-template>
<ng-template carouselSlide>Slide 2</ng-template>
<ng-template carouselSlide>Slide 3</ng-template>
</owl-carousel-o>
<div>Some tags after</div>
or
<div>Some tags before</div>
<owl-carousel-o [options]="customOptions">
<ng-container *ngFor="let slide of slidesStore">
<ng-template carouselSlide [id]="slide.id">
<img [src]="slide.src" [alt]="slide.alt" [title]="slide.title">
</ng-template>
</ng-container>
</owl-carousel-o>
<div>Some tags after</div>
please follow this link