I'm familiar with both ngRepeat
and forEach
, but what I really need is a combination of the two. Let me explain:
In my $scope
, I have a list of columns. I can display them using:
<th ng-repeat="col in columns">{{ col.label }}</th>
This will render:
<th>Col A</th>
<th>Col B</th>
<th>Col C</th>
Now, in my $scope
, there's another variable called mode
. When mode
is set to 'admin', some admin-related HTML tags are displayed using ng-show
. In this case, I would like my columns to be rendered as follows:
<th>config</th>
<th>Col A</th>
<th>config</th>
<th>Col B</th>
<th>config</th>
<th>Col C</th>
Is there a way to use ng-repeat
to render both the 'config' and the label column simultaneously? Maybe something like:
<repeat for="col in columns">
<th ng-show="mode == 'admin'">config</th>
<th>{{ col.label }}</th>
</repeat>
Alternatively, do I have to create a new list that includes admin columns and regenerate it (using forEach
) every time mode
changes? What would be the best approach in this scenario?