2
我有一个角2的应用程序,其具有在该部件的模板如下如何在angular 2模板中导入外部jquery文件?
app.component.ts
import {Component} from 'angular2/core';
@Component({
selector: 'my-app',
templateUrl: 'templates/homepage.html',
directives: []
})
export class AppComponent {
}
我需要包括在模板homepage.html外部jquery的文件
我尝试在homepage.html中包含外部脚本文件,如下所示似乎不工作
<script src="/src/js/jquery.min.js"></script>
<script src="/src/js/jquery.scrollex.min.js"></script>
<script src="/src/js/jquery.scrolly.min.js"></script>
<script src="/src/js/skel.min.js"></script>
<script src="/src/js/util.js"></script>
<script src="/src/js/main.js"></script>
boot.ts文件看起来是这样的
/// <reference path="../typings/browser.d.ts" />
import {bootstrap} from 'angular2/platform/browser';
import {AppComponent} from "./app.component";
bootstrap(AppComponent);
的index.html
<html>
<head>
<base href="/">
<title>Angular 2 Boilerplate</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Load libraries -->
<!-- IE required polyfills, in this exact order -->
<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/systemjs/dist/system-polyfills.js"></script>
<script src="node_modules/angular2/es6/dev/src/testing/shims_for_IE.js"></script>
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/rxjs/bundles/Rx.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="node_modules/angular2/bundles/router.dev.js"></script>
<script src="node_modules/angular2/bundles/http.js"></script>
<!--
<link rel="stylesheet" href="src/css/app.css"> -->
</head>
<body>
<my-app>Loading...</my-app>
<script>
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
}
}
});
System.import('app/boot')
.then(null, console.error.bind(console));
</script>
</body>
</html>
我试图加载在index.html的本身的.js文件,但不工作。我相当新的角2。
任何清洁的方式来加载多个脚本?我有5个脚本加载。 – user2180794