Window is not defined owl carousel

If you are working with Next.js and accessing the window object for the first time, there are high chances that you have seen the below error:

ReferenceError: window is not defined

In this article, we will see why this error occurs and different ways to fix the error.

Project setup

First, let's create a Next.js application using the following command:

1npx create-next-app next-window-not-defined

Reproducing the error

Once the project is setup, update the index.js with the following code:

1import styles from "../styles/Home.module.css"

3export default function Home() {

4 window.welcomeMessage = "Welcome to CodingDeft!"

5 return

Hello

Here inside the Home component, we are setting a value to

1import styles from "../styles/Home.module.css"

3export default function Home() {

4 window.welcomeMessage = "Welcome to CodingDeft!"

5 return

Hello

0. In JavaScript applications or normal react applications, this should work fine. But if we run the code and see we will see the following error:

NOTE: Each slide has an "styles": [ "node_modules/animate.css/animate.min.css" ],4. If it isn't supplied like in the first example given to p. 7, the code generates it automatically and expose one when the event "styles": [ "node_modules/animate.css/animate.min.css" ],5 fires. Info about this event is below. Follow the link .

NOTE: Custom "styles": [ "node_modules/animate.css/animate.min.css" ],4 must have the type "styles": [ "node_modules/animate.css/animate.min.css" ],8.

NOTE: Using ngx-owl-carousel-o with options "styles": [ "node_modules/animate.css/animate.min.css" ],9 and <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>0 requires adding <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>1. Steps are the following:

  1. <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>2 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>3.

  2. Add styles to <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>3:

    "styles": [ "node_modules/animate.css/animate.min.css" ],

Setting custom slides ids

It's possible to set own id to every slide.

Every "styles": [ "node_modules/animate.css/animate.min.css" ],4 must have the type "styles": [ "node_modules/animate.css/animate.min.css" ],8. Otherwise, slides won't get ids what will cause one problem, which appears when the developer uses the option <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>7. Slides won't be shown when the width of the screen changes and the carousel has to apply new settings according to the defined breakpoint. This is because the code uses ids of slides in order to assign new data to slides. So if you change the width of the screen and slides disappear, there could be the problem with setting "styles": [ "node_modules/animate.css/animate.min.css" ],4.
If "styles": [ "node_modules/animate.css/animate.min.css" ],4s aren't set explicitly, they will be created automatically.

The example of setting "styles": [ "node_modules/animate.css/animate.min.css" ],4s:

<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>

Options

ngx-owl-carousel-o uses the same options as Owl Carousel. Explanations of meanings and the usage of options are in Owl Carousel Documentation.

NOTE: ngx-owl-carousel-o has the different usage of some of them. Mostly this is about options which require setting <ng-template carouselSlide [dataMerge]="number">Slide text or HTML markup</ng-template>1 attributes to DOM-elements and which set names of classes and tags in the HTML-markup. The usage of these options is explained below.

Options which require setting <ng-template carouselSlide [dataMerge]="number">Slide text or HTML markup</ng-template>1 attributes are:

merge

The original Owl Carousel requires setting <ng-template carouselSlide [dataMerge]="number">Slide text or HTML markup</ng-template>3 to each slide besides setting <ng-template carouselSlide [dataMerge]="number">Slide text or HTML markup</ng-template>4. In this lib <ng-template carouselSlide [dataMerge]="number">Slide text or HTML markup</ng-template>3 is changed to <ng-template carouselSlide [dataMerge]="number">Slide text or HTML markup</ng-template>6 , which is the <ng-template carouselSlide [dataMerge]="number">Slide text or HTML markup</ng-template>7 property of the <ng-template carouselSlide [dataMerge]="number">Slide text or HTML markup</ng-template>8 directive. The way of setting it is:

<ng-template carouselSlide [dataMerge]="number">Slide text or HTML markup</ng-template>

the <ng-template carouselSlide [dataMerge]="number">Slide text or HTML markup</ng-template>9 must be 1, 2, 3 or any other integer numbers. If <ng-template carouselSlide [dataMerge]="number">Slide text or HTML markup</ng-template>6 isn't provided, its value will be 1 (this is the default value).

autoWidth

The option <ng-template carouselSlide [width]="number">Slide text or html markup</ng-template>1 is working if user sets the <ng-template carouselSlide [dataMerge]="number">Slide text or HTML markup</ng-template>7 prop <ng-template carouselSlide [width]="number">Slide text or html markup</ng-template>3 to <ng-template carouselSlide [dataMerge]="number">Slide text or HTML markup</ng-template>8 directive. The example:

<ng-template carouselSlide [width]="number">Slide text or html markup</ng-template>

When the <ng-template carouselSlide [width]="number">Slide text or html markup</ng-template>3 isn't provided for a certain slide and is provided for other slides, firstly it will be 0 (this is the default value). At the end it will be calculated as (width of carousel)/(items) (e.g. <ng-template carouselSlide [width]="number">Slide text or html markup</ng-template>6 and <ng-template carouselSlide [width]="number">Slide text or html markup</ng-template>7, the width of the slide will be <ng-template carouselSlide [width]="number">Slide text or html markup</ng-template>8).

In other words, the width of the slide with unprovided <ng-template carouselSlide [width]="number">Slide text or html markup</ng-template>3 will be set according to how much space in visible carousel window the slide must take. E.g. if there must be 2 visible slides, the width of the item will be half of the carousel window.

responsiveBaseElement

The option @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';00 doesn't work. In the original Owl Carousel, all responsive breakpoints are corresponding to window width. Here they are corresponding to the width of the element @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';01 which takes 100% of its parent element width.

fallbackEasing

The option @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';02 doesn't work because it's being used by @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';03 in Owl Carousel created by means of jQuery. There's no such function in Angular.

info

The option @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';04 doesn't work.

navElement, navContainer, navContainerClass, navClass, dotContainer, dotClass and dotsClass

These options don't work.

OptionExplanationnavElement: 'div'this tag is set explicitly in the View of CarouselComponentnavContainer: falseis removednavContainerClass: 'owl-nav'this css-class is set explicitly in the View of CarouselComponentnavClass: [ 'owl-prev', 'owl-next' ]this css-class is set explicitly in the View of CarouselComponentdotClass: 'owl-dot'this css-class is set explicitly in the View of CarouselComponentdotsClass: 'owl-dots'this css-class is set explicitly in the View of CarouselComponentdotsContainer: falseis removed

nestedItemSelector

The option @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';05 doesn't work.

itemElement, itemClass, stageElement, stageOuterClass, stageClass, refreshClass, loadedClass, loadingClass, rtlClass, responsiveClass, dragClass and grabClass

These options don't work.

OptionExplanationitemElement: 'div'this tag is set explicitly in the ViewitemClass: 'owl-item'this css-class is set explicitly in the ViewstageElement: 'div'this tag is set explicitly in the ViewstageClass: 'owl-stage'this css-class is set explicitly in the ViewstageOuterClass: 'owl-stage-outer'this css-class is set explicitly in the ViewrefreshClass: 'owl-refresh'this css-class is removed. Class 'owl-refreshed' is used instead. It's set explicitly in the View and reflected by OwlDOMData.isRefreshedloadedClass: 'owl-loaded'this css-class is set explicitly in the View and reflected by OwlDOMData.isLoadedloadingClass: 'owl-loading'this css-class is set explicitly in the View and reflected by OwlDOMData.isLoadingrtlClass: 'owl-rtl'this css-class is set explicitly in the View and reflected by OwlDOMData.rtlresponsiveClass: 'owl-responsive'this css-class is set explicitly in the View and reflected by OwlDOMData.isResponsivedragClass: 'owl-drag'this css-class is set explicitly in the View and reflected by OwlDOMData.isDragablegrabClass: 'owl-grab'this css-class is set explicitly in the View and reflected by OwlDOMData.isGrab

navText

NOTE: Setting options in the HTML-template in the way like

@import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';0

will cause the template parse error because of the double quote put around classes's names fa-chevron-left and fa-chevron-right. The creation of the property e.g. "styles": [ "node_modules/animate.css/animate.min.css" ],2 in @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';07 and writing @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';08 will eliminate this problem.

@import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';1

and

@import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';2

dotsData

It's needed to set it to @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';09 and to set the content in the dot for every slide using the <ng-template carouselSlide [dataMerge]="number">Slide text or HTML markup</ng-template>7 property @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';11:

@import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';3

  • in the case when @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';12 is the prop of a component.

@import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';4

  • in the case when @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';12 is simple text.

The ontent can be simple text or the HTML-markup. Dots with this option work as tabs. The option @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';14 should be set to 1, otherwise, scrolling of slides will be done by pages (1 page equals the number of visible slides). If the @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';11 isn't provided in @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';16, its values will be '' (this is the default value).

slideBy

When there's the option @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';17, disabled prev or next buttons will rewind the carousel to the start or the end accordingly. When the number of pages (dots) is 2 and there's the option @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';18, changing pages could cause thoughts something is wrong (when the carousel is on the first page, click on the prev button makes the carousel show the second page which is the ending of the carousel at the same time; in this case the next and prev button do the same job). To avoid this behavior, the number of pages must be 3 and more or it's needed to set @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';19.

The number of pages depends on the number of all slides and the option @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';14 (e.g. if the quantity of slides is @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';21 and @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';22, the number of pages will be @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';23 (10/3=3.3; 3.3 is rounded to 4)).

rewind

The documentation of Owl Carousel says the default value of this option is set to @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';09, but the code defines it as @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';25. In ngx-owl-carousel-o, its default value is set to @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';25.

WARNING: options @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';27 and @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';28 shouldn't be enabled in one carousel. They do a similar job in different ways.

freeDrag

The option @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';29 doesn't have the realization. Thus setting it to @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';09 will give nothing. This option doesn't work even in Owl Carousel written by means of jQuery.

autoplayTimeout and autoplaySpeed

The option @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';31 must always be bigger than the option @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';32. Otherwise, the autoplay won't work.

autoplayMouseleaveTimeout

This options works just in the case @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';33 is enabled. @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';34 sets the value of just the first timeout after firing the event @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';35. Default meaning is @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';36. Then the value of @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';31 is applied.

URLhashListener

When the option @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';38, it's required to define the <ng-template carouselSlide [dataMerge]="number">Slide text or HTML markup</ng-template>7 prop @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';40 in @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';41:

@import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';5

 or

@import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';6

where @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';42 is the object with hashes (fragments) of url. @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';42 could be an array. Defining the kind of data store is up to the developer.

NOTE: @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';44 uses services @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';45 and @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';46 for making it possible to navigate by hashes (fragments). And if @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';47 isn't imported in the main module of an application, the problem will appear. @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';44 won't work. Therefore it's needed to import @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';47 in the main module of an application even in the case of creating the simple app for testing the work of the library.

lazyLoad

There's no need to set to @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';50 attributes @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';51 and @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';52 because Angular has its own realization for @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';50. In Angular it's better to write @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';54. @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';55 is the data-binding, which means Angular will set the value to the native attribute @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';55 of @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';50 after loading its core code. Original Owl Carousel reads @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';51 and sets the native attribute @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';55 at needed moment. Of course, ngx-owl-carousel-o has additional tricks for lazy loading images (better to say the content of slides) put into slides.

skip_validateItems

By default, this option is set to @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';25. This option changes the number of visible slides in the case, when the number of slides is less than the value of the option @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';14. For example, when the <ng-template carouselSlide [width]="number">Slide text or html markup</ng-template>7 and there're just 3 slides, the carousel will reassign the value of @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';14 to @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';64.

When the option @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';65 is @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';09, the carousel won't reassign the @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';14. So, in the example above @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';14 will remain @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';23. But there will be 3 slides and one empty place. This for the case when the option @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';18. When @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';19, the empty place will be populated by the copy of the first slide.

owlRouterLink

The directive <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>9 is introduced for making impossible the navigating between components while the carousel is dragging.

This directive has the same features as the native @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';73 directive. One exception is the property @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';74. It prevents the navigating to another component.

This directive is included into "styles": [ "node_modules/animate.css/animate.min.css" ],1, which must be imported into a needed module before using the @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';76. So, to use this directive, you just need to write it inside the needed slide.

Example of usage this directive:

@import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';7

@import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';77 contains <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>9 directive and its @Input property @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';74.

@import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';80 is also possible way of using this directive.

In the example above, we see the usage of @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';81 event, <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>9, and @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';74. When the dragging of the carousel starts, the @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';81 event notifies about it by passing object

@import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';8

The value of the prop @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';81 is assigned to the @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';86 property. Then this property is passed into <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>9 through @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';74. Directive gets aware of dragging the carousel and prevents any navigations.

When the dragging of the carousel is finished, @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';81 passes object

@import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';9

@import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';86 gets updated, which causes the change of @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';74. Now its value is @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';25. This enables navigating during the next simple click on <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>8 locating in the slide unless new dragging starts.

So, to use <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>8 in any slide, it's recommended to:

  • use @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';81 event and property @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';96 (or named differently);
  • use <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>9 directive;
  • use @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';74 property of <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>9. It's needed to pass to this prop @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';96. Using of @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';74 is required.

The real example is here.

The import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}02 has the automatic preventing navigation during dragging.

Events

  • .
  • .
  • .
  • .
  • .

translated

It fires after the carousel finishes translating and exposes the object of the type import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}03.

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

import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}04 is the position of the first slide with the class import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}05

import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}06 is the array with data of each active slide. Data of each active slide are:

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

The code for subscribing to this event is the following:

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

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

import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}08 is the subscription or attaching to the event;

import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}09 is the method which takes data about active slides.

import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}10 is the property of import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}07, which stores data about active slides

dragging

The event @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';81 fires after that the user starts dragging the carousel. It exposes the object

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

When the dragging of the carousel is started its paylod is:

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

The prop import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}13 shows the situation which was at the moment of starting dragging. In other words, if before dragging the carousel the prop import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}04 was import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}15, the event @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';81 will emit this prop with the same value.

When the dragging of the carousel is finished and the event "styles": [ "node_modules/animate.css/animate.min.css" ],5 is fired @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';81 fires again but its payload has value

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

This time, the prop import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}13 shows current import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}04 and current active import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}06.

This event is needed for the cases when slide should contain the tag <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>8 with the @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';73 directive.

Example of using this event:

@import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';7

import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}24 This expression uses the @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';81 event and has the property @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';96 which should be created in the component hosting the import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}27.

import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}28 is the payload of the event. Its prop @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';81 can be @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';09 or @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';25. The real example is here.

initialized

It fires after the carousel gets initialized and exposes the object of the type import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}03.

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

import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}04 is the position of the first slide with the class import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}05

import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}06 is the array with data of each active slide. Data of each active slide are:

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

The code for subscribing to this event is the following:

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

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

import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}37 is the subscription or attaching to the event;

import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}38 is the method which takes data about active slides.

import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}10 is the property of import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}07, which stores data about active slides

change

It fires after each change in the carousel (click on dots, nav buttons). However, while the user drags the carousel this event fires after dropping the carousel or after stopping dragging. This event exposes the object of the type import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}03. It's populated by data defined before firing the event. This event just notifies about changes. New data (active slides, startPosition) gets available after the end of moving the carousel (event "styles": [ "node_modules/animate.css/animate.min.css" ],5).

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, }; }0

import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}04 is the position of the first slide with the class import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}05

import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}06 is the array with data of each active slide. Data of each active slide are:

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

The code for subscribing to this event is the following:

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

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, }; }2

import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}47 is the subscription or attaching to the event;

import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}38 is the method which takes data about active slides.

import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}10 is the property of import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}07, which stores data about active slides

changed

It fires when user clicks dots or nav buttons and new data about active slides becomes known. This event fires before the event "styles": [ "node_modules/animate.css/animate.min.css" ],5 gets fired. However, while the user drags the carousel this event fires after dropping the carousel or after stopping dragging. This event exposes the object of the type import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}03:

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, }; }0

import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}04 is the position of the first slide with the class import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}05

import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}06 is the array with data of each active slide. Data of each active slide are:

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

The code for subscribing to this event is the following:

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

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, }; }5

import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}57 is the subscription or attaching to the event;

import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}38 is the method which takes data about active slides.

import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}10 is the property of import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}07, which stores data about active slides

Plugins

ngx-owl-carousel-o has almost all plugins written on the page Owl Carousel Plugin API except the VideoPlugin.

VideoPlugin

This plugin isn't realized. In order to play the video, use special packages (e.g. import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}61; import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}62 and so on).

It's better to create special component with the video and put it in import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}63 The example:

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, }; }6

"styles": [ "node_modules/animate.css/animate.min.css" ],4 and import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}65 are data-binding properties, defined in the component which contains import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}66.

Tips

Real examples to help

Some examples of using this lib are displayed in the app demo-owl-carousel:

  • The carousel with <ng-template carouselSlide [width]="number">Slide text or html markup</ng-template>1. Typescript part and HTML part
  • The carousel with import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}68, @import '~ngx-owl-carousel-o/lib/styles/scss/owl.carousel'; @import '~ngx-owl-carousel-o/lib/styles/scss/owl.theme.default';38 and import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}70. Typescript part and HTML part
  • The carousel with import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}71. Typescript part and HTML part

NOTE: demo-owl-carousel could be downloaded and started on own PC. Steps for achieving that are:

  • import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}72;
  • import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}73 or import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}74;
  • import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}75 or import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}76.

Tests to help

Also, lots of variants of using carousel are in files carousel.component.spec.ts and stage.component.spec.ts.

They contain tests of the library. These tests include many functions import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}77. The example:

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, }; }7

The first argument of import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}77 explains how the carousel should work with options written in import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}79. In this example the height of the carousel should change automatically: import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}80.

Variable import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}81 contains the HTML-markup of the carousel for import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}82.

However, most of the HTML-markups set to import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}81 are simplified. There's no property "styles": [ "node_modules/animate.css/animate.min.css" ],2, directive import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}85 and import { CarouselModule } from 'ngx-owl-carousel-o'; @NgModule({ imports: [CarouselModule], declarations: [CarouselHolderComponent], }) export class SomeModule {}86 as it is in examples above.

Managing the carousel from outside its markup

It's possible to move the carousel left/right and to needed slide from different places of the html-page. The real is provided in home.component.html

Toplist

Última postagem

Tag