2

i installed jquery plugin in angular 2 project Link

npm i jquery-bootstrap-scrolling-tabs

and add in .angular-cli.json

 "styles": [
        "styles.css",
        "../node_modules/jquery-bootstrap-scrolling-tabs/dist/jquery.scrolling-tabs.css"
      ],
      "scripts": [
        "../node_modules/jquery/dist/jquery.js",
         "../node_modules/jquery-bootstrap-scrolling-tabs/dist/jquery.scrolling-tabs.js"
      ],

and i declare the veritable typings.d.ts

declare var scrollingTabs:any;

using in app.component.ts

ngAfterViewInit() {
    $('.nav-tabs').scrollingTabs({
      scrollToTabEdge: true  
    });
  } 

error: TypeError: __WEBPACK_IMPORTED_MODULE_1_jquery___default(...)(...).scrollingTabs is not a function

2 Answers 2

2

you forgot to add the jquery variable

declare var $ : any

For more info on how to add jquery use this LINK with and without typings

Sign up to request clarification or add additional context in comments.

2 Comments

added still not working. scrollingTabs is not a function
i would suggest you to use view child and add the template reference to the function instead of the class, tell me if you need a example
1

Import jquery in your component file.

declare let $ : any

1 Comment

any difference from what i added 9 minutes ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.