How do I let Angular propagate the changes i did to the model. In AngularJS this would be really easy, but i cannot seem to get it working in Angular. I know the entire change detection system and view propagation is changed entirely. Somehow, i need to inform angular of the changes. But how can i do this in practise.
See this piece of typescript code:
import {Component, View, bootstrap, For} from 'angular2/angular2';
// Annotation section
@Component({
selector: 'app'
})
@View({
template: `
<div *for="#user of users">
{{user}}
</div>
`,
directives: [For]
})
class App {
users:Array<String>;
constructor() {
this.users = [];
this.fillUsersAsync();
}
fillUsersAsync(){
window['fetch']('http://jsonplaceholder.typicode.com/users')
.then( resp => resp.json())
.then( users => users.forEach(user => this.users.push(user.name)))
.then( () => console.log('Retrieved users and put on the model: ', this.users));
}
}
bootstrap(App);
You will see that, after the users get loaded into the model, the view doesn't update.
I'm using systemjs 0.16, angular 2.0.0-alpha.23.
See this plnkr for the example (currently, works only in chrome, as the new 'fetch' api is used)