Working on a TODO-app to learn Angular. I have this hardcoded array as a "database" and i want to display the tasks in the view.
var taskLists = [
{name: 'Todays todo', id: '1', tasks:['Make coffe', 'another task']},
{name: 'Tomorrow i will do this', id: '2', tasks:['Code well', 'go to bed']}
];
So how do i iterate through an array inside an array in an angular-view?
I tried to have two ng-repeats but cant get it to work right. I want to display the tasks one by one as <td>
, not just the whole tasks array as one <td>
as it does right now ['Make coffe', 'another task']
This is what the view looks like.
<h2 ng-repeat="object in list">{{object.name}}</h2>
<table>
<thead>
<tr>Tasks</tr>
</thead>
<tr>
<td ng-repeat="task in list">{{task.tasks}}</td>
</tr>
</table>
ng-repeat
shouldn't beng-repeat="task in object.task"
? – Patrick Ferreira Jun 2 '14 at 14:30task in object.tasks
. Plus the HTML from the answer below did the trick. – Bullfinch Jun 2 '14 at 14:53<h2>
tag, i did not notice that :-) – Patrick Ferreira Jun 2 '14 at 14:55