javascript - How to get started with angular2 in nw.js -


how can working 'hello world' angular 2 under nw.js?

i got working angular 2 app using guide:

https://angular.io/docs/js/latest/quickstart.html

and working nw.js app using one:

https://egghead.io/lessons/javascript-your-first-nw-js-desktop-application-in-less-than-5-minutes

combining 2 this:

package.json:

{   "name": "angular2-quickstart",   "version": "1.0.0",   "license": "isc",   "dependencies": {     "angular2": "2.0.0-beta.0",     "systemjs": "0.19.6",     "es6-promise": "^3.0.2",     "es6-shim": "^0.33.3",     "reflect-metadata": "0.1.2",     "rxjs": "5.0.0-beta.0",     "zone.js": "0.5.10"   },   "description": "",   "main": "index.html",   "scripts": {     "test": "echo \"error: no test specified\" && exit 1"   },   "author": "" } 

index.html:

<html>    <head>     <title>angular 2 quickstart</title>      <!-- 1. load libraries -->     <script src="env/lib/node_modules/angular2-quickstart/node_modules/angular2/bundles/angular2-polyfills.js"></script>     <script src="env/lib/node_modules/angular2-quickstart/node_modules/rxjs/bundles/rx.umd.js"></script>     <script src="env/lib/node_modules/angular2-quickstart/node_modules/angular2/bundles/angular2-all.umd.js"></script>      <!-- 2. load our 'modules' -->     <script src='app/app.component.js'></script>     <script src='app/boot.js'></script>    </head>    <!-- 3. display application -->   <body>     <my-app>loading...</my-app>   </body>  </html> 

app/boot.js:

(function(app) {   document.addeventlistener('domcontentloaded', function() {     ng.platform.browser.bootstrap(app.appcomponent);   }); })(window.app || (window.app = {})); 

app/app.component.js:

(function(app) {   app.appcomponent =     ng.core.component({       selector: 'my-app',       template: '<h1>my first angular 2 app</h1>'     })     .class({       constructor: function() {}     }); })(window.app || (window.app = {})); 

to install node , dependencies ran (i ended node 5.4.1; nodeenv https://pypi.python.org/pypi/nodeenv/0.13.6):

nodeenv --prebuilt env source env/bin/activate npm install -g nw npm install -g 

then run app under nw:

nw . 

if replace index.html simple plain html 'hello world', see display in nw fine. however, angular 2 index.html, see "loading..." message app in browser, , on terminal launched nw:

[22627:0117/010210:error:browser_main_loop.cc(170)] running without suid sandbox! see https://code.google.com/p/chromium/wiki/linuxsuidsandboxdevelopment more information on developing sandbox on. attention: default value of option force_s3tc_enable overridden environment. [22627:0117/010210:error:nw_shell.cc(336)] typeerror: cannot read property 'prototype' of undefined     @ object.apply (file:///home/me/dev/angular2-quickstart/env/lib/node_modules/angular2-quickstart/node_modules/angular2/bundles/angular2-polyfills.js:941:35)     @ object.apply (file:///home/me/dev/angular2-quickstart/env/lib/node_modules/angular2-quickstart/node_modules/angular2/bundles/angular2-polyfills.js:835:22)     @ object.apply (file:///home/me/dev/angular2-quickstart/env/lib/node_modules/angular2-quickstart/node_modules/angular2/bundles/angular2-polyfills.js:301:27)     @ object.<anonymous> (file:///home/me/dev/angular2-quickstart/env/lib/node_modules/angular2-quickstart/node_modules/angular2/bundles/angular2-polyfills.js:38:14)     @ object.1.../core (file:///home/me/dev/angular2-quickstart/env/lib/node_modules/angular2-quickstart/node_modules/angular2/bundles/angular2-polyfills.js:40:4)     @ s (file:///home/me/dev/angular2-quickstart/env/lib/node_modules/angular2-quickstart/node_modules/angular2/bundles/angular2-polyfills.js:19:254)     @ e (file:///home/me/dev/angular2-quickstart/env/lib/node_modules/angular2-quickstart/node_modules/angular2/bundles/angular2-polyfills.js:19:425)     @ file:///home/me/dev/angular2-quickstart/env/lib/node_modules/angular2-quickstart/node_modules/angular2/bundles/angular2-polyfills.js:19:443 [22627:0117/010210:info:console(941)] "uncaught typeerror: cannot read property 'prototype' of undefined", source: file:///home/me/dev/angular2-quickstart/env/lib/node_modules/angular2-quickstart/node_modules/angular2/bundles/angular2-polyfills.js (941) [22627:0117/010211:error:nw_shell.cc(336)] reflect-metadata shim required when using class decorators [22627:0117/010211:info:console(2398)] "uncaught reflect-metadata shim required when using class decorators", source: file:///home/me/dev/angular2-quickstart/env/lib/node_modules/angular2-quickstart/node_modules/angular2/bundles/angular2-all.umd.js (2398) [22627:0117/010211:error:nw_shell.cc(336)] referenceerror: ng not defined     @ window.app.window.app (file:///home/me/dev/angular2-quickstart/app/app.component.js:3:5)     @ file:///home/me/dev/angular2-quickstart/app/app.component.js:10:3 [22627:0117/010211:info:console(3)] "uncaught referenceerror: ng not defined", source: file:///home/me/dev/angular2-quickstart/app/app.component.js (3) [22627:0117/010211:error:nw_shell.cc(336)] referenceerror: ng not defined     @ htmldocument.<anonymous> (file:///home/me/dev/angular2-quickstart/app/boot.js:3:5) [22627:0117/010211:info:console(3)] "uncaught referenceerror: ng not defined", source: file:///home/me/dev/angular2-quickstart/app/boot.js (3) [22656:0117/010213:warning:channel.cc(553)] failed send message remove remote endpoint (local id 2147483649, remote id 3) [22656:0100/000000:warning:channel.cc(553)] failed send message remove remote endpoint (local id 1, remote id 1) 

i'm on linux.

it looks angular javascript file not being loaded. why ng undefined believe.

to enable toolbar development purposes place following property setting in package.json file.

 "toolbar": true, 

take @ following screenshot can begin troubleshooting.

enter image description here

after click on network tab hit f5 refresh page can see files have , have not loaded.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -