How to install and use the library of js in npm in ionic.

Asked 2 months ago, Updated 2 months ago, 4 views

Library of Social Shares jsocials

I am trying to use .

npm install jsocials

I installed it in , but I don't know how to use it after this.
The documentation shows how to use jsocials as follows:

<!DOCTYPE html>
<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"/>
<script src="jquery.js"></script>
<script src="jsocials.min.js"></script>
        shares: ["email", "twitter", "facebook", "googleplus", "linkedin", "pinterest", "stumbleupon", "whatsapp" ]

With ionic, I think you will use the module in the import statement.

import {method name, etc} from 'library name'

I think is the syntax, but if you want to use a library like the one above.
What should I write in the {} of the import statement?

typescript ionic2

2022-09-30 11:45

1 Answers

I don't know the specific story of ionic, but jsocials are not provided as JavaScript modules, so I use them as ambient declarations.
You should also need an additional jquery type definition file.npm [email protected]/jquery

I think I can use the following jsocials.d.ts at least.

interface JsSocials{
    (arg:any): any;

interface JQuery {
    jsSocials —JsSocials;

2022-09-30 11:45

If you have any answers or tips

© 2022 OneMinuteCode. All rights reserved.