Owl Carousel with Angular

Owl Carousel with Angular

Owl Carousel with Angular - Today I am going to create a demo of owl carousel with angular 6. This is one of the very common topics while working on web application development.

Owl Carousel with Angular - Today I am going to create a demo of owl carousel with angular 6. This is one of the very common topics while working on web application development.

Let's Get Started

If you have not installed Angular latest version in your system then read getting started with angular.

Now let's proceed to create the demo.

Step 1: Create Angular App

Create a new angular app by typing below command over terminal

ng new owl-carousel

Step2: install dependencies

Now after the successfull app creation, Move to the project folder with *cd owl-carousel/ * and install required npm packages.

npm install ngx-owl-carousel owl.carousel jquery --save

In the above command we have installed 3 npm packages, ngx-owl-carousel is used for rich carousel feature of jQuery to get integrated with Angular. Owl.carousel is the main package where the actual task performs. jQuery is needed for main Owl carousel to work.

Step 3: Add library files in angular.json

In angular.json at root of the project, add library script and styles like below:

"styles": [
"src/styles.css",
"./node_modules/owl.carousel/dist/assets/owl.carousel.min.css",
"./node_modules/owl.carousel/dist/assets/owl.theme.default.min.css"
],
"scripts": ["./node_modules/jquery/dist/jquery.min.js",
"./node_modules/owl.carousel/dist/owl.carousel.min.js"]
},

Step 4: Update app.module.ts file

import { OwlModule } from 'ngx-owl-carousel';

// Add OwlModule to imports at below section

imports: [

BrowserModule,

OwlModule

],

Step 5: Update app.component.ts file

import { Component } from '@angular/core';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'owl-carousel';

mySlideImages = ['../assets/images/image1.jpg','../assets/images/image2.jpeg','../assets/images/image3.jpg'];
myCarouselImages =['../assets/images/image1.jpg','../assets/images/image2.jpeg','../assets/images/image3.jpg'];

mySlideOptions={items: 1, dots: true, nav: true};
myCarouselOptions={items: 3, dots: true, nav: true};
}

In the above code we have generated a static array of images we will have in owl-carousel. Also we have updated here the default setting of the slider.

Step 6: Update app.component.html file

<owl-carousel [options]="mySlideOptions" [items]="images" [carouselClasses]="['owl-theme', 'sliding']" >
<div class="item" *ngFor="let image of mySlideImages;let i = index">
<div>
<img src={{image}}/>
</div>
</div>
</owl-carousel>

Conclusion

In this demo, we used the npm packages for owl-carousel. Find the official documentation here.

That’s all for now. Thank you for reading and I hope this post will be very helpful for integrating owl carousel in angular app.

angular web-development

What's new in Bootstrap 5 and when Bootstrap 5 release date?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Random Password Generator Online

HTML Color Picker online | HEX Color Picker | RGB Color Picker

Hire Dedicated eCommerce Web Developers | Top eCommerce Web Designers

Build your eCommerce project by hiring our expert eCommerce Website developers. Our Dedicated Web Designers develop powerful & robust website in a short span of time.

Best Web and App Development Company in Ahmedabad

Contact DataPierce for any questions or queries you have about website development, designing, marketing projects or any small or enterprise software development.

Important reasons for developers to adopt Angular JS development

In the current scenarios, e-commerce companies are very keen to create an online impact. The web and app development market are at its peak of popularity. There is a high demand for web and app developers with a growing number of websites. Angular...

Mobile App Development Company India | Ecommerce Web Development Company India

Best Mobile App Development Company India, WebClues Global is one of the leading web and mobile app development company. Our team offers complete IT solutions including Cross-Platform App Development, CMS & E-Commerce, and UI/UX Design.

For World Class Web Development Services in India visit RB Genie

Do you want excellent and world class web development services for your valuable projects? Contact **RB Genie **now, we have more than 8 years experienced team of web developers, which specializes in overall web design and website development...