<!DOCTYPE html>
<html>

  <head>
    <title>angular2 playground</title>
    <link href="style.css" rel="stylesheet" />
<!--     Owl carousel styles 1.3.3
<link href="https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.carousel.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.theme.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.transitions.min.css" rel="stylesheet"  />
End owl carousel styles -->
    
    
    <!-- Owl carousel styles 2.1.6-->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.1.6/assets/owl.carousel.min.css" rel="stylesheet" />
    <link href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.1.6/assets/owl.theme.default.min.css" rel="stylesheet" />
    <link href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.1.6/assets/owl.theme.green.min.css" rel="stylesheet"  />
    <!-- End owl carousel styles --> 



    <script src="https://code.angularjs.org/2.0.0-beta.8/angular2-polyfills.js"></script>
    <script src="https://code.angularjs.org/tools/system.js"></script>
    <script src="https://code.angularjs.org/tools/typescript.js"></script>
    <script src="config.js"></script>
    <script src="https://code.angularjs.org/2.0.0-beta.8/Rx.js"></script>
    <script src="https://code.angularjs.org/2.0.0-beta.8/angular2.dev.js"></script>
    <script src="https://code.angularjs.org/2.0.0-beta.8/http.dev.js"></script>
    <script>
    System.import('app')
      .catch(console.error.bind(console));
  </script>
  </head>

  <body>
    <h2>How to use owl-carousel 2 in Angular2?</h2>
    <app>loading...</app>
  </body>

</html>
/* Styles go here */

### Angular2 Starter Plunker - Typescript - Beta 0

A simple plunker demonstrating Angular2 usage:
- Uses SystemJS + TypeScript to compile on the fly
- Includes binding, directives, http, pipes, and DI usage.
System.config({
  //use typescript for compilation
  transpiler: 'typescript',
  //typescript compiler options
  typescriptOptions: {
    emitDecoratorMetadata: true
  },
  //map tells the System loader where to look for things
  map: {
    app: "./src",
    jquery: 'https://code.jquery.com/jquery-2.2.3.min.js',
    'owl-carousel': 'https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.1.6/owl.carousel.js' 
    // 'owl-carousel': 'https://cdnjs.cloudflare.com/ajax/libs/owl-carousel/1.3.3/owl.carousel.min.js'

  },
  
  meta: {
    'owl-carousel': {
      deps: ['jquery']
    }
  },
  
  //packages defines our app package
  packages: {
    app: {
      main: './main.ts',
      defaultExtension: 'ts'
    }
  }
});
//main entry point
import {bootstrap} from 'angular2/platform/browser';
import {App} from './app';

bootstrap(App, [])
  .catch(err => console.error(err));
//our root app component
import {Component} from 'angular2/core';
import { OwlCarousel } from './owl-carousel.component';

@Component({
  selector: 'app',
  directives: [OwlCarousel],
  template: `
    <h3>Sample 1</h3>
    <owl-carousel [options]="{navigation: true, pagination: false, rewindNav : false}">
       <div *ngFor="#item of items1">
         <p>{{ item }}</p>
       </div>
    </owl-carousel>
    <h3>Sample 2</h3>
    <button (click)="f = !f">Test</button>
    <div *ngIf="f">
    <owl-carousel [options]="{navigation: false, pagination: true, rewindNav : false}">
       <div *ngFor="#item of items2">
         <p>{{ item }}</p>
       </div>
    </owl-carousel>
    </div>
    <h3>Sample 3</h3>
    <owl-carousel [options]="{navigation: false, pagination: true, rewindNav : false}">
       <div *ngFor="#img of images">
         <img src="http://lorempixel.com/400/200/{{img}}"/>
       </div>
    </owl-carousel>`
})
export class App {
  items1: Array<number> = [1, 2, 3, 4, 5];
  
  items2: Array<number> = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
  
  images: Array<string> = ['sports', 'abstract', 'people', 'transport', 'city', 'technics', 'nightlife', 'animals'];
}
import { Component, Input, ElementRef, HostBinding } from 'angular2/core';
import $ from 'jquery';
import 'owl-carousel';

@Component({
  selector: 'owl-carousel',
  template: `<ng-content></ng-content>`
})
export class OwlCarousel {
  @HostBinding('class') defaultClass = 'owl-carousel';
  @Input() options: object;
  
  f = true;
  
  $owlElement: any;

  defaultOptions: any = {};

  constructor(private el: ElementRef) {}

  ngAfterViewInit() {
    // use default - empty
    // for (var key in this.options) {
    //   this.defaultOptions[key] = this.options[key];
    // }
    this.$owlElement = $(this.el.nativeElement).owlCarousel(this.defaultOptions);
  }

  ngOnDestroy() {
    this.$owlElement.owlCarousel('destroy');
    this.$owlElement = null;
  }
}