Currently, I am utilizing a template that I purchased from Theme Forest as the foundation for an angular application.
My goal is to transform these template parts into components.
However, I am facing difficulties in getting a Revolution slider to work.
Within the template HTML, the slider is set up on the document ready event:
<script>
jQuery(document).ready(function() {
jQuery("#rev_slider_280_1").show().revolution({
sliderType: "hero",
jsFileLocation: "revo-slider/js/",
sliderLayout: "fullscreen",
dottedOverlay: "none",
delay: 9000,
/*navigation: {},*/
responsiveLevels: [1240, 1024, 778, 480],
visibilityLevels: [1240, 1024, 778, 480],
gridwidth: [1240, 1024, 778, 480],
gridheight: [868, 768, 960, 720],
lazyType: "none",
parallax: {
type: "off",
origo: "slidercenter",
speed: 1000,
levels: [0],
type: "scroll",
disable_onmobile: "on"
},
shadow: 0,
spinner: "spinner2",
autoHeight: "off",
fullScreenAutoWidth: "off",
fullScreenAlignForce: "off",
fullScreenOffsetContainer: "",
fullScreenOffset: "",
disableProgressBar: "on",
hideThumbsOnMobile: "off",
hideSliderAtLimit: 0,
hideCaptionAtLimit: 0,
hideAllCaptionAtLilmit: 0,
debugMode: false,
fallbacks: {
simplifyAll: "off",
disableFocusListener: false,
}
});
}); /*ready*/
</script>
When approaching a similar task in Angular, the OnInit lifecycle hook is typically used.
I have imported jQuery and captured the DOM element successfully.
The main obstacle lies in obtaining a reference to the Revolution library.
Whenever I try to use the following code in Angular, I encounter a compile-time error stating: "Property 'Revolution' does not exist on jQuery:"
import {Component, ElementRef, OnInit} from '@angular/core';
import * as $ from 'jquery';
@Component({
selector: 'pm-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
title = 'pm';
constructor(private element: ElementRef) {}
ngOnInit(): void {
$(this.element.nativeElement).show().revolution({
sliderType: "hero",
jsFileLocation: "revo-slider/js/",
sliderLayout: "fullscreen",
dottedOverlay: "none",
delay: 9000,
/*navigation: {},*/
responsiveLevels: [1240, 1024, 778, 480],
visibilityLevels: [1240, 1024, 778, 480],
gridwidth: [1240, 1024, 778, 480],
gridheight: [868, 768, 960, 720],
lazyType: "none",
parallax: {
type: "off",
origo: "slidercenter",
speed: 1000,
levels: [0],
type: "scroll",
disable_onmobile: "on"
},
shadow: 0,
spinner: "spinner2",
autoHeight: "off",
fullScreenAutoWidth: "off",
fullScreenAlignForce: "off",
fullScreenOffsetContainer: "",
fullScreenOffset: "",
disableProgressBar: "on",
hideThumbsOnMobile: "off",
hideSliderAtLimit: 0,
hideCaptionAtLimit: 0,
hideAllCaptionAtLilmit: 0,
debugMode: false,
fallbacks: {
simplifyAll: "off",
disableFocusListener: false,
}
});
}
}