Ad

Angular 2 + JSPM: Not Working As Expected

I have Angular 2 (beta.6) installed using JSPM. When I then start my app I get the message of 'reflect-metadata' being required (see also Angular2 + Jspm.io : reflect-metadata shim is required when using class decorators). Installing this also via JSPM solves the issue.

But then I stumble on the next problem. The ngFor is not giving me the expected behavior. When I add records to a list of a component, it doesn't get updated. I tried adding them via click-event handlers and setTimeout, etc. but it doesn't seem to trigger the so called 'application tick'.

Ad

Answer

After some digging through the code I found that: to have the ngFor update, you need to include zone.js since angular 2 depends on it. When it isn't there it is just silently ignored.

So what you have to do is look at the dependencies that angular 2 got in its 'package.json' which are currently: 1. es6-promise 2. es6-shim 3. reflect-metadata 4. rxjs 5. zone.js

Install all of them using JSPM and you should be good to go.

Ad
source: stackoverflow.com
Ad