angular-cli: 如何添加外部库 (jquery, bootstrap)

angular-cli: how to add external libraries (jquery, bootstrap)

目前我要做的事情:

在index.html

<script src="assets/jquery/jquery.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<link href="assets/bootstrap/css/bootstrap.min.css" rel="stylesheet">

有什么更好的方法吗?

看完你就会明白:

https://github.com/angular/angular-cli#3rd-party-library-installation

基本上你只需要将它添加到 angular-cli.json 文件中的 scripts 属性 (apps[0]).

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