0

Right now I have the following html:

<body ng-controller="defaultCtrl">
<table>
<thead>
  <tr>
    <th>Default</th>
    <th ng-if="c">A</th>
    <th ng-if="c">B</th>
    <th ng-if="c">C</th>
    <th ng-if="c">D</th>
  </tr>
</thead>
</table>
</body>

If $scope.c exists in my defaultCtrl, I want A, B, C, D to appear as table headers.

How can I group ng-if instead of repeating it 4 times?

When I try to put the four elements in a div or span, I'm getting an error message saying that I'm invoking voodoo mode.

2
  • 1
    Do you really get an error that says voodoo mode? :) you might include the error message in your question... Commented Sep 20, 2014 at 21:31
  • You cannot group th's inside a span or div, which is invalid html. It must appear only within tr.. Commented Sep 20, 2014 at 21:37

1 Answer 1

2

Well, you can definitely do it like this

<th ng-if="c" ng-repeat="x in ['A', 'B', 'C', 'D']">{{x}}</th>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.