All Projects → mujtaba01 → ngx-owl-carousel

mujtaba01 / ngx-owl-carousel

Licence: MIT license
An angular2 (4) wrapper for jquery owl-carousel library with dynamic carousel item change detection

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to ngx-owl-carousel

angular-preloading-strategies
A demo of custom preloading strategies with Angular
Stars: ✭ 13 (-81.69%)
Mutual labels:  angular2
ng2-fontawesome
An easy-to-use directive for font awesome icons.
Stars: ✭ 20 (-71.83%)
Mutual labels:  angular2
nodeJS examples
Server, routing, db examples using NodeJS v6
Stars: ✭ 34 (-52.11%)
Mutual labels:  angular2
puppy-love
A cryptographically secure couple matching platform with strong guarantees
Stars: ✭ 61 (-14.08%)
Mutual labels:  angular2
ng-pdf-make
This is library creates a bridge to use pdfmake library with your angular 2 implementation.
Stars: ✭ 15 (-78.87%)
Mutual labels:  angular2
v-owl-carousel
🦉 VueJS wrapper for Owl Carousel
Stars: ✭ 46 (-35.21%)
Mutual labels:  owl-carousel
NG2-Admin-Asp-Core-Boilerplate
Multi API Admin panel developed on ASP.NET Boilerplate, Bootstrap 4, and Angular2 (typescript). For frond-end theme is used ng2 admin theme.
Stars: ✭ 31 (-56.34%)
Mutual labels:  angular2
angular2-webpack-advance-starter
An advanced Angular2 Webpack Starter project with support for ngrx/store, ngrx/effects, ng2-translate, angulartics2, lodash, NativeScript (*native* mobile), Electron (Mac, Windows and Linux desktop) and more.
Stars: ✭ 49 (-30.99%)
Mutual labels:  angular2
angular2-simple-countdown
a simple countdown angular2 directive with multiple language
Stars: ✭ 26 (-63.38%)
Mutual labels:  angular2
ng2-storage
A local and session storage wrapper for angular 2.
Stars: ✭ 14 (-80.28%)
Mutual labels:  angular2
ng2-acl
Role based permissions for Angular v2++
Stars: ✭ 15 (-78.87%)
Mutual labels:  angular2
angular-build-info
🛠 A CLI to generate an easily importable `build.ts` file containing various details about the application build
Stars: ✭ 25 (-64.79%)
Mutual labels:  angular2
ionic-video-chat-support
Ionic 3 Video and Group Text Chat
Stars: ✭ 19 (-73.24%)
Mutual labels:  angular2
material-todo
Angular Material Design Todo App
Stars: ✭ 27 (-61.97%)
Mutual labels:  angular2
laravel5Angular4
Laravel 5.4 & Angular 4.3.4
Stars: ✭ 37 (-47.89%)
Mutual labels:  angular2
typesafe-i18n
A fully type-safe and lightweight internationalization library for all your TypeScript and JavaScript projects.
Stars: ✭ 1,227 (+1628.17%)
Mutual labels:  angular2
paper-dashboard-angular
Angular version of the original Paper Dashboard.
Stars: ✭ 142 (+100%)
Mutual labels:  angular2
ngx-json-ld
📝 A small component to easily bind JSON-LD schema to Angular templates.
Stars: ✭ 29 (-59.15%)
Mutual labels:  angular2
ngx-widget-grid
Angular 2.x or in general ng-x module for dashboards
Stars: ✭ 65 (-8.45%)
Mutual labels:  angular2
ng2-3d-editor
3D Viewer and Editor Javascript
Stars: ✭ 15 (-78.87%)
Mutual labels:  angular2

ngx-owl-carousel

Dependencies

This Library requires jquery and owl.carousel to be installed globally

For commonJs based application load jquery and owl.carousel using script loader or use link tag in html file

Install script-loader if you don't have already

npm install script-loader

and in vendor.ts

require('script!jquery');
require('script!owl.carousel');

OR

inside index.html put this inside the head tag

<script type="application/javascript" src="/node_modules/jquery/dist/jquery.js"></script>
<script type="application/javascript" src="/node_modules/owl.carousel/dist/owl.carousel.js"></script>

If using angular-cli

Add this to angular-cli.json file

"scripts": [
    "../node_modules/jquery/dist/jquery.js",
    "../node_modules/owl.carousel/dist/owl.carousel.js"
]

Installation

To install this library, run:

$ npm install ngx-owl-carousel --save

and then from your Angular AppModule:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';

// Import your library
import { OwlModule } from 'ngx-owl-carousel';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    OwlModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Import required css files

Include these two css files

  1. owl.carousel.css file This is required css files.

  2. owl.theme.default file This file is optional. However to use default navigation controls or dots buttons this file is necessary.

Inside angular-cli.json add these lines:

"styles": [
    "../node_modules/owl.carousel/dist/assets/owl.carousel.css",
    "../node_modules/owl.carousel/dist/assets/owl.theme.default.css"
]

OR include these files in main scss file.

import "~owl.carousel/dist/assets/owl.carousel.css";
import "~owl.carousel/dist/assets/owl.theme.default.css";

OR include these files in index.html file inside head tag.

    <link rel="stylesheet" href="/node_modules/owl.carousel/dist/assets/owl.carousel.min.css">
    <link rel="stylesheet" href="/node_modules/owl.carousel/dist/assets/owl.theme.default.min.css">

Once your library is imported, you can use OwlCarousel component very easily in your Angular application:

<!-- You can use owl-carousel selector to include its component -->
 <owl-carousel
     [options]="{items: 3, dots: false, navigation: false}"
     <!-- If images array is dynamically changing pass this array to [items] input -->
     [items]="images"
     <!-- classes to be attached along with owl-carousel class -->
     [carouselClasses]="['owl-theme', 'row', 'sliding']">
     <div class="item" *ngFor="let image of images;let i = index">
         <div class="thumbnail-image" [ngStyle]="{'background': 'url(abc.jpg) no-repeat scroll center center / 80px 80px'}"></div>
     </div>
 </owl-carousel>

Note: Please remove comments from the above example else you will get errors.

Angular Universal Integration

This package is a wrapper for the jquery library owl.carousel. Jquery is not supported in Angular Universal currently. Therefore the carousel cannot be rendered server side. However if you are using angular universal, do not include owl.carousel ("/node_modules/owl.carousel/dist/owl.carousel.js") in server side configuration.

APIs

  1. next(options?: any[])

    • To go to next slide. Animation time can be passed as options array. E.g. this.owlElement.next([200]). (200ms animation time).
  2. previous(options?: any[])

    • To go to previous slide. (arguments are similar)
  3. to(options?: any[])

    • To go to nth slide. (arguments are similar)
  4. trigger(action: string, options?: any[])

    • To trigger any jquery owl carousel's action. options can be passed accordingly.
<owl-carousel #owlElement
import {OwlCarousel} from 'ngx-owl-carousel';

export class HomeComponent {
@ViewChild('owlElement') owlElement: OwlCarousel


   fun() {
     this.owlElement.next([200])
     //duration 200ms
   }
}

Callbacks

All callbacks listed in native owl carousel's documentation https://owlcarousel2.github.io/OwlCarousel2/docs/api-events.html can be used in options properties.

Callbacks list:

  • onInitialize
  • onInitialized
  • onResize
  • onResized
  • onDrag
  • onDragged
  • onTranslate
  • onTranslated
  • onChange
  • onChanged
  • onLoadLazy
  • onLoadedLazy
  • onPlayVideo
  • onStopVideo

License

This project is licensed under the terms of the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].