I'm new to the AngularJS and currently stuck at what's stated in the title, that is dynamically generating columns in the table. My case is: from Python (and to be more specific, Django), I'm passing dict and list: list contains column names ('Week X', where X coresponds to week number) and dict looks like this:
data : {
'Person A': {
'Week 1' : {
'Task 1': True,
'Task 2': False,
},
'Week 2' : {
'Task 1': True,
'Task 2': True,
},
},
'Person B': {
'Week 1' : {
'Task 1': True,
'Task 2': False,
},
'Week 2' : {
'Task 1': False,
'Task 2': False,
},
},
}
And this structure is changing as number of weeks is changing. I would like to have it dynamically generated so it would look like this:
First thing that came to my mind was to create, let's say, column template and then repeat it for every element in the list. But that's the place where I encountered the problem - I just couldn't do so and each new column was added below previous one. My code looked like this:
<table>
<thead>
<th>Person ID</th>
<th ng-repeat="week in weeks order by $index">
<tr>
<td>{{ week }}</td>
</tr>
<tr>
<td>Task 1</td>
<td>Task 2</td>
</tr>
</th>
</thead>
<tbody>
<tr ng-repeat='person in data'>
<td>{{ person }}</td>
<td>{{ Task 1 }}</td>
<td>{{ Task 2 }}</td>
</tr>
</tbody>
</table>
And additionaly, I would like to loop over tasks, meaning I would like to dynamically create and fill columns with data per specific week for specific person, but I don't know how to - I can't just put ng-repeat in <td> and I don't know with which html tag I could achieve this.
