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'.
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.
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM