0

Im new to angular, currently working with version 5. I have to install a plugin called 'jquery-circle-progress', which can be found here: http://kottenator.github.io/jquery-circle-progress/

I've installed it with via npm, and added the .js file to .angular-cli.json scripts array. It seems to load fine, and I can activate it with jquery via browsers console, so this part is ok.

I just dont know how to run it from inside the component. I have to update this progress bar every minute or so, so I wanna make a function in mycomponent.component.ts, which fetches some data, checks it, and runs some jquery to update the progress bar.

I just cant get this progress-bar's function to be available here. It just says that '.circleProgress is not available'.

BTW I can get jquery to run inside of the .ts file, via:

import * as $ from 'jquery';

I dont know how to also get circle progress bar in here.

Any help is more than welcome.

2

1 Answer 1

2

You need to import the plugin code in your angular.json (used to be angular-cli.json) file in scripts array:

"scripts": [
      "node_modules/jquery/dist/jquery.js",
      "node_modules/nouislider/distribute/nouislider.min.js",
]

As you can see above, you can also import jQuery in there - first node module. The next is a jQuery plugin I had to use in my project.

Then create a new Angular wrapper component that will hold the jQuery plugin and initialise it in ngOnInit() method and eventually do the cleanup in ngOnDestroy() method. At the top of your component drop this declare var $:any; You don't have to use import * as $ from 'jquery'; since jQuery is imported into your app in angular.json file.

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

Comments

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.