How to use the js library installed with npm

I want to user jssocials

I installed it with the following command.

npm install jssocials

I do not know how to use it after this.
In the document, the basic usage is described as follows.

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="font-awesome.css" />
    <link rel="stylesheet" type="text/css" href="jssocials.css" />
    <link rel="stylesheet" type="text/css" href="jssocials-theme-flat.css" />
</head>
<body>
    <div id="share"></div>

    <script src="jquery.js"></script>
    <script src="jssocials.min.js"></script>
    <script>
        $("#share").jsSocials({
            shares: ["email", "twitter", "facebook", "googleplus", "linkedin", "pinterest", "stumbleupon", "whatsapp"]
        });
    </script>
</body>
</html>

In ionic, import the library with an import statement.
import { myFunction } from ‘theLibraryName’;

If you want to use jssocials, how do you write an import statement?
In the library name section,
‘jssocials’
I think that I will write.
But,
{ myFunction }
I do not know what to write in the place of.

1 Like

Where is the npm package page? Example: here’s a page for a component I wrote: https://www.npmjs.com/package/star-rating-web-component

Also, general comment: don’t use jquery with Ionic 3. You will be able to use it with Ionic 4 if you don’t use Angular. But you can’t decouple Angular from Ionic 3.

Thank you for your prompt reply.
The following is the page of npm.

When using the following in the ts file, does not it need not write an import statement somewhere?
Will newRating be available only by installing at npm?

newRating(ratingEvent: CustomEvent) {
    let rating: number = ratingEvent.detail;
    console.log('New rating: ',rating);
}

I better not to use jquery!

you mean for my component? In Ionic 3, you do this. It’s more complicated than a pure Javascript module, because it’s a Stencil component. It probably doesn’t affect your situation with jssocials.

I don’t think this library is a good fit for Ionic 3. You can probably get it to work, but jquery competes with Angular, and can slow things down. You could wait for Ionic 4 and use it then, or look now for a different social network library that works better with Angular.

OK.

I will not use this library
Thanks!

What about:

I tried it, but when I ran the browser,
angular is not defined
I get an error saying.