सरल प्रश्न, मुझे आशा है।
मैं एक स्क्रिप्ट चलाना चाहता हूं जब Angular2 $ डॉक्यूमेंट के बराबर हो। पहले से ही निकाल दिया गया है। इस लक्ष्य को हासिल करने का सबसे अच्छा तरीका क्या है?
मैंने स्क्रिप्ट को अंत में डालने की कोशिश की है index.html, लेकिन जैसा कि मुझे पता चला है, यह काम नहीं करता है! मैं इसे लेता हूं कि इसे किसी तरह के घटक घोषणा में जाना है?
क्या किसी .jsफ़ाइल से स्क्रिप्ट लोड करना संभव है ?
संपादित करें - कोड:
मैं अपने आवेदन ( फाउंड्री HTML विषय से ) में निम्नलिखित जेएस और सीएसएस प्लग इन मिला है ।
<link href="css/themify-icons.css" rel="stylesheet" type="text/css" media="all" />
<link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="all" />
...
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/flexslider.min.js"></script>
...
<script src="js/scripts.js"></script> //This initiates all the plugins
जैसा कि कहा गया है, लिपियों। जे एस पूरी बात 'Instantiates', और इस प्रकार कोणीय तैयार होने के बाद चलाने की आवश्यकता है। script.js
यह काम कर गया:
import {Component, AfterViewInit} from 'angular2/core';
@Component({
selector: 'home',
templateUrl: './components/home/home.html'
})
export class HomeCmp implements AfterViewInit {
ngAfterViewInit() {
//Copy in all the js code from the script.js. Typescript will complain but it works just fine
}