角2 PhoneGap的不工作(普通的JavaScript) [英] Angular 2 in Phonegap doesn't work (plain javascript)
问题描述
我在平原建立与角2网站的JavaScript和一切它的浏览器工作正常,但是当我尝试建立phonegapp应用程序或PhoneGap的移动应用使用它,它不工作。
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.
在index.html的我有:
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>
和上main.js我有:
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})
]);
}
};
所以,我包括 ng.platform.browser.bootstrap
时,设备已准备就绪。 (也试图与 document.addEventListener('DOMContentLoaded',函数(){...}
但同样的结果。
So I include ng.platform.browser.bootstrap
when device is ready. (Also tried with document.addEventListener('DOMContentLoaded', function() {...}
but with same result.
所有的,我可以看到它载入中......那么&LT;应用&GT;加载...&LT; /应用&GT;
这是由角PTED不跨$ P $。
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.
推荐答案
您需要添加垫片
,使其工作的PhoneGap
。这可以是 ES6-shim.js
/ ES5-shim.js
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.
这篇关于角2 PhoneGap的不工作(普通的JavaScript)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!