Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kamalkech opened this issue Feb 8, 2017 · 11 comments
Closed
Labels
needs: investigation Requires some digging to determine if action is needed type: RFC / discussion / question

Comments

@kamalkech
Copy link

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 ?

@rajeshtandukar
Copy link

Same Problem here :(

@RicardoVaranda
Copy link
Contributor

@kamalkech @rajeshtandukar

You will be able to fix this issue by using:

npm install --save-dev @types/owlcarousel

@filipesilva
Copy link
Contributor

Closing as answered.

@dereklin
Copy link

This is failing at runtime for me:

__WEBPACK_IMPORTED_MODULE_2_jquery__(...).owlCarousel is not a function

How did you guys work owlCarousel work with cli?

@amitgaur208
Copy link

Problem not solved with npm install --save-dev @types/owlcarousel

@RicardoVaranda
Copy link
Contributor

Do you also have jquery types installed?

@amitgaur208
Copy link

amitgaur208 commented Mar 20, 2017

@RicardoVaranda Yes. I have installed it already with command npm install script-loader

@RicardoVaranda
Copy link
Contributor

@amitgaur208 Could you create a repo project and upload it to github so I can pull and fix it, will be easier this way to see what modifications are required, thanks!

@filipesilva filipesilva reopened this Mar 20, 2017
@filipesilva filipesilva added needs: investigation Requires some digging to determine if action is needed type: RFC / discussion / question labels Mar 20, 2017
@dereklin
Copy link

This is how I fixed the problem and made it work: dereklin/angular-cli-owl-carousel@bd6b30a

@filipesilva
Copy link
Contributor

Closing as inactive.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: investigation Requires some digging to determine if action is needed type: RFC / discussion / question
Projects
None yet
Development

No branches or pull requests

6 participants