简体   繁体   中英

using third party library in angular

How can i use third party library in angular 4? Normally i used code below :

 <html> <head> <title>Bootstrap CDN Simple Example</title> <link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"> </head> <body> <h1> Bootstrap CDN Simple Complete HTML Example</h1> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script> </body> </html>

There are two ways to achieve that.

You can simply add the <script> to your index.html file, like you described above and then access it through declare var google: any; (or whatever name your library has).

Here's an example for using google maps in angular.

Or you can install the library from npm (with the accoriding types) and simply import it like this:

import * as _ from "lodash";

Here's an example for this approach.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM