Good evening!
Is it possible to use Angular 2 (2.0.0-beta.0) in nw? Have you got any experience with it?
When I use Angular 2 with lite server it works. If I use it inside NW it will broke. Polyfills wanted to use websockets, maybe that is the missing part? Is it replaceable?
I'm trying with these files (copied from Angular's docs):
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/rxjs/bundles/Rx.umd.js"></script>
<script src="node_modules/angular2/bundles/angular2-all.umd.js"></script>
Any advice is more than welcomed. Thanks.
Could you upload a full sample app?
We documented an image issue of AngularJS in FAQ. See FAQ
Sure, I made a repo for that https://github.com/kisPocok/nw-angular-example
@kisPocok Your sample has 2 problems: 1. package.json is not a valid JSON. There is a trailing comma in the "scripts" fields. 2. app.Subtitle doesn't exist.
The problem to use Angular in NW is that Angular is going to create variable global which is already created by NW. That will affect the exception handling for Angular, so that you won't see any error messages when loading your app. A workaround is that you can rename global to anything else, like nw_global before loading any Angular libraries. For example,
<script>
window.nw_global = window.global;
window.global = undefined;
</script>
<!-- Angular 2 Dependencies -->
I will document the the globals added by NW to normal browser context.
I had to cleanup my package.json, it had too many irrelevant packages. So, it's not the case.
The second part is promising, I'm going to try it today. Thanks.
@ghostoy fixed my problem thanks!!
I will document this in FAQ section.
@ghostoy will u please open a wiki to intro how to start up nwjs with angular2/vue/react. yo is much more prefer.
@fuchao2012 Wiki is open for editing by anyone. You can do it :smiley:
Most helpful comment
@kisPocok Your sample has 2 problems: 1.
package.jsonis not a valid JSON. There is a trailing comma in the "scripts" fields. 2.app.Subtitledoesn't exist.The problem to use Angular in NW is that Angular is going to create variable
globalwhich is already created by NW. That will affect the exception handling for Angular, so that you won't see any error messages when loading your app. A workaround is that you can renameglobalto anything else, likenw_globalbefore loading any Angular libraries. For example,