简体   繁体   English

如何将jQuery插件添加到angular-cli项目

[英]How to add a jquery plugin to angular-cli project

I have already added a jquery library in to my angular-cli project but i also need to add jquery form validate plugin on the top of the jquery. 我已经在我的angular-cli项目中添加了一个jquery库,但是我还需要在jquery的顶部添加jquery form validate插件。 I also want to integrate it with my component.ts file. 我也想将其与我的component.ts文件集成在一起。 how can i do this. 我怎样才能做到这一点。

THANK YOU FOR YOUR HELP! 谢谢您的帮助!

First install jQuery using npm as follows 首先使用npm安装jQuery,如下所示

npm install jquery — save

Include it on your cli.json file 将其包含在您的cli.json文件中

"scripts": [ "../node_modules/jquery/dist/jquery.min.js" ]

Import 进口

 import * from 'jquery';
    (or)
    declare var $: any;

Component 零件

 public ngOnInit()
  {
    $(document).ready(function(){
        $("someclick").click(function(){

        });
    });
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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