简体   繁体   中英

How to use external js library functions in Angular 7 project?

We are creating one project in angular 7. We want to use jquery based library as image picker.

We have imported the library correctly as import * as 'image-picker' from '..asset/image-picker.min.js'

Also it has been imported as script in index.js with correct path.

Now we are getting stuck about the correct use of this file in Typescript environment. For example how to use the below example method of the above library in Angular Module in component and templates.

You CANNOT use jquery based libs in Angular context. It was clearly not a good practice with the old fashionned AngularJS 1.**, now it's not even possible.

EDIT :

According to this source , it's seem's possible. But for me, it's clearly not a good idea to insist on using Jquery with Angular 7

I saw this library using jquery so If you using external library you need to include script of that library in your website using script tag or if you using angular cli you need to edit your angular.json and include that script

then use it in your method

$("select").imagepicker()

You can go to my blog to read detail how to integrate third party library to angular here

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