question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Angular 2 and Owl carousel 2 / erro : $(...).owlCarousel is not a function

See original GitHub issue

OS?

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:closed
  • Created 7 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

10reactions
dereklincommented, Mar 20, 2017
5reactions
RicardoVarandacommented, Feb 13, 2017

@kamalkech @rajeshtandukar

You will be able to fix this issue by using:

npm install --save-dev @types/owlcarousel
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found