Reputation: 3002
I build a website with angular 2 in plain javascript and everything it's working ok in browser, but when I try to build phonegapp app or use it with Phonegap Mobile app it doesn't 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 include ng.platform.browser.bootstrap
when device is ready. (Also tried with document.addEventListener('DOMContentLoaded', function() {...}
but with same result.
All that I can see it's Loading... so <app>Loading...</app>
it's not interpreted by angular.
Do you have any idea what I should change to work? Thanks.
Upvotes: 4
Views: 2308
Reputation: 136134
You need to add shims
to make it working on phonegap
. That can be either es6-shim.js
/es5-shim.js
Probably that will solve your issue.
Upvotes: 3