I am writing an angular 2 app. In the quick start tutorial, all things are working fine but in my todo app, its not working.
app.component.ts
import {Component, Template, View, NgFor, bootstrap, CORE_DIRECTIVES, FORM_DIRECTIVES} from 'angular2/angular2';
@Component({
selector: 'todo-app',
})
@View({
directives : [NgFor, CORE_DIRECTIVES, FORM_DIRECTIVES]
})
@Template({
url: 'components/todo-app/todo-app.html'
})
class TodoAppComponent {
todos : Array;
constructor() {
this.todos = [];
TodoFactory.getAll().then((data) =>{
this.todos = data; // I got JSON in todos object.
});
}
}
todo-app-html
<div *ng-for='#todo of todos'>
{{ todo.text }}
</div>
In my template, *ng-for
is not working. Even when I try {{ todos }}
, it shows all of the data. I searched a lot and found that I should pass NgFor
core directives to the template like directives : [NgFor]
This is also not working. Any single help would be appreciated.