Angular 2 on Phonegap not working (plain javascript)

I am creating a website with angular 2 in simple javascript and everything that works in the browser, but when I try to create a phonegapp application or use it using the Phonegap Mobile application, it does not work.

In index.html, I have:

<body>
        <app>Loading app...</app>



        <!-- 1. Load libraries -->
        <script src="libs/angular/2.0.0-beta.3/angular2-polyfills.js"></script>
        <script src="libs/angular/2.0.0-beta.3/Rx.umd.js"></script>
        <script src="libs/angular/2.0.0-beta.3/angular2-all.umd.js"></script>


        <!-- 2. Load our 'modules' -->
        <script src='app/services.build.js'></script>        <!-- All our services, as server comunication -->
        <script src='app/components.build.js'></script>      <!-- All the components -->
        <script src='app/app.component.js'></script>            <!-- App component, main one -->
        <script src='app/main.js'></script>                     <!-- Main -->

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

And on main.js I have:

var phonegapApp = {
    initialize: function() {
        this.bindEvents();
    },
    bindEvents: function() {
        document.addEventListener('deviceready', this.onDeviceReady, false);
    },
    onDeviceReady: function() {
        ng.platform.browser.bootstrap(AppComponent,[
            ng.router.ROUTER_PROVIDERS,
            new ng.core.Provider(ng.router.LocationStrategy, {useClass: ng.router.HashLocationStrategy})
        ]);
    }
};

So, I turn it on ng.platform.browser.bootstrapwhen the device is ready. (Also tried with document.addEventListener('DOMContentLoaded', function() {...}, but with the same result.

All that I can see. Loading ... this is <app>Loading...</app>not interpreted by angular.

Do you have any ideas what I should change to work? Thanks.

+4
source share
1 answer

shims, phonegap. es6-shim.js/es5-shim.js

, .

+4

Source: https://habr.com/ru/post/1629010/


All Articles