简体   繁体   中英

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'.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM