2016-03-30 12 views
2

I einen Winkel 2 app, die eine Vorlage in dem Bauteil alsWie importiert man externe jquery-Dateien in Angular 2 Vorlage?

folgt

import {Component} from 'angular2/core'; 

@Component({ 
    selector: 'my-app', 
    templateUrl: 'templates/homepage.html', 
    directives: [] 
}) 
export class AppComponent { 

} 

app.component.ts I externe jquery Dateien in der Vorlage homepage.html

umfassen müssen ich habe versucht, einschließlich der externen Skriptdateien im homepage.html wie folgt nicht scheint nicht

<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 Datei zu arbeiten, sieht aus wie dieses

/// <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>  

ich die Js-Dateien in der index.html selbst versucht, das Laden, aber das funktioniert nicht. Ich bin ziemlich neu in Winkel 2.

Antwort

Verwandte Themen