如何在Angular2组件之前加载其他文件

时间:2017-01-31 10:12:06

标签: javascript jquery twitter-bootstrap angular

是否可以在Angular 2加载之前加载某个文件?目前我在jQuery, bootstrap, file.js全局加载angular-cli.json,包括它,这样当你启动Angular时会捆绑。

是否可以先在Angular之前加载file.js?我还需要为此file.js加载jQuery,因为它有一些jQuery http请求。我尝试将../node_modules/jQueryangular-cli.json移到我的index.html。

Angular-cli.json - 当file.js在angular-cli.json中时

"scripts": [
    "../node_modules/jquery/dist/jquery.js",
    "../node_modules/bootstrap/dist/js/bootstrap.js",
    "./assets/js/file.js"
  ],

index.html - 当我在索引中移动jQuery和file.js时,我没有定义jQuery。

// in head tag
<script src="../node_modules/jquery/dist/jquery.js"></script>
<script src="../node_modules/bootstrap/dist/js/bootstrap.js"></script>
<script src="./assets/js/config/env.js"></script>

1 个答案:

答案 0 :(得分:0)

在.ts文件的顶部,您要使用td[data-key="serial_no"], td[data-key="name"], td[data-key="code"], td[data-key="date"], td[data-key="serial_no"]" ($),导入以下内容:

jQuery

现在,您可以将import $ from 'jquery'; 用于与jquery相关的事情。