From what I understand, you can not use server-side rendering and directly manipulate native elements, how do I use renderer2?
import { Component, Input, ElementRef, HostBinding, OnInit, Renderer2 } from '@angular/core';
import $ from 'jquery';
import 'owl.carousel';
@Component({
selector: 'app-owl-carousel',
template: '<ng-content></ng-content>'
})
export class OwlCarouselComponent implements OnInit {
@HostBinding('class') defaultClass = 'owl-carousel';
@Input() options: object;
$owlElement: any;
defaultOptions: any = {};
constructor(private el: ElementRef, private renderer: Renderer2 ) { }
ngOnInit(){}
ngAfterViewInit() {
this.$owlElement = $(this.el.nativeElement).owlCarousel(this.defaultOptions);
}
ngOnDestroy() {
this.$owlElement.owlCarousel('destroy');
this.$owlElement = null;
}
}