2017-02-17 2 views
0

Ich habe eine einfache angular2-Anwendung, und ich möchte eine mobile App für diese App mit Cordova erstellen. Wie kann ich diese Web App in eine mobile App umwandeln, ohne ionic und nativeScrypte zu verwenden?konvertiert eckig 2 Web-App auf mobile App

+1

Mögliche Duplikat [Drehen Angular JS 2 app in mobile app] (http://stackoverflow.com/questions/37649500/turn-angular-js-2-app-into-mobile-app) – ishandutta2007

Antwort

0

Unabhängig davon, welche Quelle Sie übertragen haben, kopieren Sie sie in den www-Ordner von cordova.

Ich werde dies in Bezug auf Angular CLI erklären.

Ich erstellte zwei Projekte, eine Angular CLI & eine Cordova.

In Angular CLI Konfig json, ich hielt Produktion o/p Dir -> Cordova www Verzeichnis.

Dann, wann immer ich baue --prod, es automatisch hält die transpiled src in cordova www & Dann in der Lage, eine Cordova bauen.

Um den Prozess zu vereinfachen, schrieb ich 1 Cordova-Haken, der vor cordova build/run baut.

const fs = require('fs'); 
const execSync = require('child_process').execSync; 



module.exports = function(context) { 
    const basePath = context.opts.projectRoot; 
    const baseWWW = basePath + '/www'; 

process.chdir('../bmi-surgical-app'); 
console.log(`New directory: ${process.cwd()}`); 

    execSync("ng build --prod --base-href .",{stdio:[0,1,2]}); 

    var files = fs.readdirSync(baseWWW); 
    for (var i = 0; i < files.length; i++) { 
     if (files[i].endsWith('.gz')) { 
     fs.unlinkSync(baseWWW + '/' + files[i]); 
     } 
    } 
    fs.writeFileSync(baseWWW + '/.gitignore', `# Ignore everything in this directory 

* 
# Except this file 
!.gitignore 
`); 


}; 
+0

es funktioniert, aber die mobile app ist immer in laden es nicht anythings, – kasri

+0

es funktioniert, aber die mobile app ist immer in laden es keine dinge anzeigen, es zeigt keine daten, die meine appcompanents enthält – kasri

+0

Öffnen browser-konsole und überprüfen error console welcher fehler es anzeigt ... ich schätze ihr fehler ist nicht richtig basis href –