[英]using jQuery globally within Angular 2 application
I'm trying to figure out how to use jQuery globally within my angular 2 app, the only reasonable source I found so far is this stackoverflow answer However I can't seem to get it working. 我正试图弄清楚如何在我的角度2应用程序中全局使用jQuery,到目前为止我找到的唯一合理的来源是这个stackoverflow答案但是我似乎无法让它工作。 Is there a way to achieve this with npm
package management instead of tsd (this command is not working for me, I assumed it is coming from typescript, but seems like not). 有没有办法用npm
包管理而不是tsd来实现这个目标(这个命令对我不起作用,我认为它来自于typescript,但似乎没有)。
After this, I think I need to reference jQuery within my app.ts file? 在此之后,我想我需要在app.ts文件中引用jQuery? (main file used by bootstrap.ts to boot the application) (bootstrap.ts用来启动应用程序的主文件)
Here is my project structure 这是我的项目结构
app
components
app.ts
services
typings
bootstrap.ts
index.html
and few code examples I believe need to be used for jQuery implementation 我认为需要用于jQuery实现的代码示例很少
app.ts app.ts
import {Component, View} from 'angular2/core';
@Component({
selector: 'app',
templateUrl: 'app/components/app.html'
})
export class App { }
bootstrap.ts bootstrap.ts
import {App} from './components/app';
bootstrap(App);
Install the jquery typings using: 使用以下命令安装jquery打字:
npm install @types/jquery
Include the jQuery.js
file in your index.html
在index.html
包含jQuery.js
文件
And.. that's it I guess :) 而且......我想是的:)
Good luck 祝好运
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.