2016-08-02 24 views
1

我一直在嘗試在我的ionic 2應用程序中使用soundcloud javascript sdk soundcloud javascript sdk。但我不知道如何使SC對象在我的服務模塊中可見。 我已經在我的index.html中包含了sdk,就像這樣 我試圖確保SC對象可以通過th模塊運行,但是我得到一個ts錯誤,說找不到mobile SC。 如何在angular2模塊中使用Soundcloud javascript sdk

export class SCService { 
 
    constructor() { 
 
    \t console.log(SC); 
 
    } 
 

 
}
<ion-app></ion-app> 
 
    <script src="https://connect.soundcloud.com/sdk/sdk-3.1.2.js"></script> 
 
    <!-- cordova.js required for cordova apps --> 
 
    <script src="cordova.js"></script> 
 
    <!-- Polyfill needed for platforms without Promise and Collection support --> 
 
    <script src="build/js/es6-shim.min.js"></script> 
 
    <!-- Zone.js and Reflect-metadata --> 
 
    <script src="build/js/Reflect.js"></script> 
 
    <script src="build/js/zone.js"></script> 
 
    <!-- the bundle which is built from the app's source code --> 
 
    <script src="build/js/app.bundle.js"></script>

回答

0

聲明一個變量SC類的外部,然後用它的組件內部

declare var SC: any; 
0

就使用這樣的window['SC'].Widget.Events類似SC.Widget.Events正常。

相關問題