在Angular 2应用程序中全局使用jQuery
我试图弄清楚如何在我的角度2应用程序中全局使用jQuery,到目前为止我找到的唯一合理的来源是这个stackoverflow答案但是我似乎无法让它工作。 有没有办法用npm
包管理而不是tsd来实现这个目标(这个命令对我来说不起作用,我认为它来自于typescript,但似乎没有)。
在此之后,我想我需要在app.ts文件中引用jQuery? (bootstrap.ts用来启动应用程序的主文件)
这是我的项目结构
app components app.ts services typings bootstrap.ts index.html
我认为需要用于jQuery实现的代码示例很少
app.ts
import {Component, View} from 'angular2/core'; @Component({ selector: 'app', templateUrl: 'app/components/app.html' }) export class App { }
bootstrap.ts
import {App} from './components/app'; bootstrap(App);
使用以下命令安装jquery类型:
npm install @types/jquery
在index.html
包含jQuery.js
文件
而且……我想是的:)
祝好运