Angular 2 and Owl carousel 2 / erro : $(...).owlCarousel is not a function
See original GitHub issueOS?
Windows 10
Versions.
angular-cli: 1.0.0-beta.28.3 node: 6.9.4 os: win32 x64
Repro steps.
I put this in angular-cli.json :
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.css",
"../node_modules/owl.carousel/dist/assets/owl.carousel.css",
"styles.css"
],
"scripts": [
"../node_modules/jquery/dist/jquery.js",
"../node_modules/owl.carousel/dist/owl.carousel.js",
"../node_modules/tether/dist/js/tether.js",
"../node_modules/bootstrap/dist/js/bootstrap.js"
],
- In file component i put this :
import { Component, OnInit, AfterViewInit } from '@angular/core';
import 'rxjs';
declare var $:any;
@Component({
selector: 'app-owl-carousel',
templateUrl: './owl-carousel.component.html',
styleUrls: ['./owl-carousel.component.css']
})
export class OwlCarouselComponent implements OnInit, AfterViewInit {
constructor() { }
ngOnInit() {
}
ngAfterViewInit(): void {
$('.owl-example').owlCarousel();
}
}
The log given by the failure.
EXCEPTION: Uncaught (in promise): Error: Error in :0:0 caused by: $(…).owlCarousel is not a function TypeError: $(…).owlCarousel is not a function at OwlCarouselComponent.ngAfterViewInit (http://localhost:4200/main.bundle.js:28:27) at CompiledTemplate.proxyViewClass.View_OwlCarouselComponent_Host0.detectChangesInternal (/AppModule/OwlCarouselComponent/host.ngfactory.js:32:79) at CompiledTemplate.proxyViewClass.AppView.detectChanges
Any idea ?
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
angular 2 owlCarousel is not a function
I get an error ERROR TypeError: $(...).owlCarousel is not a function . I don't see why this error should pop up. I've ordered...
Read more >How to fix "Uncaught TypeError: $(…).owlCarousel is not a ...
So I'm using this following technique to get rid of the error: (function($) { $(document).ready(function(){ $("#owl-demo").owlCarousel({
Read more >Uncaught TypeError: $(...).owlCarousel is not a function
I researched and tried putting In the head. <script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min ...
Read more >Slider Error on Mozilla : owlCarousel is not a function
Hello,. I have a problem with my frontpage, especially with my slider. It works well on Google Chrome but I have a problem...
Read more >How can I fix? Uncaught TypeError: $(...).owlCarousel is not a ...
owlCarousel is not a function at yttheme.min.js:2. Hello,. I get this error on all pages. (Magento 2.3).
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is how I fixed the problem and made it work: https://github.com/dereklin/angular-cli-owl-carousel/commit/bd6b30acfee00f60516b541a4da6c5608a2b7b25
@kamalkech @rajeshtandukar
You will be able to fix this issue by using: