How to import jQuery to Angular2 TypeScript projects?

前端 未结 7 1957
一向
一向 2020-12-01 14:48

I want to wrap some jQuery code in an Angular2 directive.

I installed jQuery library for Typings into my project with the following command:

typings in

7条回答
  •  北荒
    北荒 (楼主)
    2020-12-01 15:18

    I don't think it should be a issue to use jquery with angular 2. If the typings and the dependencies for jquery are installed properly, then it should not be a issue to use jquery in angular 2.

    I was able to use jquery in my angular 2 project with proper installation. And by proper installation, I mean the installation of jquery typings in order to recognize it in typescript.

    After that, I was able to use jquery in following way:

    jQuery(document).ready({
        ()=>{
            alert("Hello!");
        };
    });
    

提交回复
热议问题