2016-03-29 32 views
1

我已經創建了Angular2 + Typescript Web應用程序。它在瀏覽器中正常工作。使用Phonegap將此Web應用程序轉換爲移動應用程序(android)後,它僅呈現靜態HTML。它不加載任何angular2組件或功能,也不會在屏幕上引發任何錯誤。Phonegap - Angular2應用程序不能在移動中加載

這裏是index.html的

<!DOCTYPE html> 
<html lang="en"> 

<head> 
    <!--<base href="/">--> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0" /> 
    <title>My Goal Tracker</title> 

    <!-- CSS --> 
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> 
    <link href="css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection" /> 
    <link href="css/style.css" type="text/css" rel="stylesheet" media="screen,projection" /> 

    <script type="text/javascript" src="cordova.js"></script> 
    <script type="text/javascript"> 
     phonegapApp.initialize(); 
    </script> 


    <!-- 1. Load libraries --> 
    <!-- IE required polyfills, in this exact order --> 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.35.0/es6-shim.min.js"></script> 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.20/system-polyfills.js"></script> 
    <script src="https://npmcdn.com/[email protected]/es6/dev/src/testing/shims_for_IE.js"></script> 

    <script src="https://code.angularjs.org/2.0.0-beta.12/angular2-polyfills.js"></script> 
    <script src="https://code.angularjs.org/tools/system.js"></script> 
    <script src="https://npmcdn.com/[email protected]/lib/typescript.js"></script> 
    <script src="https://code.angularjs.org/2.0.0-beta.12/Rx.js"></script> 
    <script src="https://code.angularjs.org/2.0.0-beta.12/angular2.dev.js"></script> 
    <script src="https://code.angularjs.org/2.0.0-beta.12/router.dev.js"></script> 



    <!-- 2. Configure SystemJS --> 
    <script> 
     System.config({ 
     packages: {   
      app: { 
      format: 'register', 
      defaultExtension: 'js' 
      } 
     } 
     }); 
     System.import('app/main') 
      .then(null, console.error.bind(console)); 
    </script> 

</head> 

<body> 

    <home>Loading...</home> 

    <footer class="page-footer orange"> 
     <div class="footer-copyright"> 
      <div class="container"> 
       Made by <a class="orange-text text-lighten-3" href="http://uvbrain.com">UVBrain Solutions</a> 
      </div> 
     </div> 
    </footer> 

    <!-- Scripts--> 
    <script src="https://code.jquery.com/jquery-2.1.1.min.js"></script> 
    <script src="js/materialize.js"></script> 
    <script src="js/init.js"></script> 

</body> 

</html> 

的PhoneGap項目結構如下: enter image description here

有誰請讓我知道可能是什麼問題?

在此先感謝!

+0

[看這個類似的問題](http://stackoverflow.com/questions/35436047/angular-2-in-phonegap-doesnt-work-plain-javascript) –

+0

@Chavan你真的使用* Phongap Build *和* Phonegap CLI *。這是不正常的。 Corodova/Phonegap有三(3)種不同的系統[CLI,SDK或Build](https://github.com/jessemonroy650/top-phonegap-mistakes/blob/master/new-to-Phonegap.md#001) 。你在用哪個? – JesseMonroy650

+0

@ JesseMonroy650,我使用Phonegap Desktop應用程序創建了空白應用程序。然後在www文件夾中放上我的angular2網站代碼。之後,我運行了phonegap serve命令並在我的手機上進行了測試。 – Chavan

回答

-3

在發出調試日誌和警報後,我發現了這個問題。這是導致問題的NG2的路由機制。

+0

我有同樣的問題,你是如何解決這個問題的? –

+2

我不認爲這是一個答案,請提供一個。 – Goowik

相關問題