2016-11-27 42 views
-1

我需要有可用的jQuery到我的我的應用程序,這樣我可以使用這樣在全球範圍內加載的Jquery在Angularjs 2應用

進口的jQuery的所有組成部分;並在所有組件中使用jquery api

我正在使用SystemJS,Angular 2和typescript。我怎樣才能做到這一點?

問候

+0

POSS Ible重複[如何使用jQuery與Angular2?](http://stackoverflow.com/questions/30623825/how-to-use-jquery-with-angular2) – Fiddles

回答

0

您需要導入您的應用程序的jQuery $和必須配置您的systemjs裝載機在jQuery庫將可

//in your typescript angular2 
    import * as $ from 'jQuery'; 

    // in your systemjs configuration 
    //map 

    (function(global) { 
    // map tells the System loader where to look for things 
    var map = { 
    'app':      'app', // 'dist', 
    'jQuery':      'node_modules/jQuery/lib/node-jquery.js', 
    }; 

您還可以導入它在你的HTML的index.html像下面

System.import('jQuery').catch(function(err){ console.error(err); }); 

調整你的自我,使工作

+0

非常感謝你,它的作品就像一個魅力.. .. – shabari