0

Here's my code:

<tbody>
      <tr ng-repeat-start="person in people">
        <td>
          <button ng-if="person.expanded" ng-click="person.expanded = false">-</button>
          <button ng-if="!person.expanded" ng-click="person.expanded = true">+</button>
        </td>

        <td>{{person.name}}</td>
        <td>{{person.gender}}</td>
        <td>
          <button ng-if="person.expanding" ng-click="person.expanding = false">-</button>
          <button ng-if="!person.expanding" ng-click="person.expanding = true">+</button>
        </td>
      </tr>
      <tr ng-if="person.expanded" ng-repeat-end="">
        <td colspan="3">{{person.details}}</td>
      </tr>
      <tr ng-if="person.expanding" ng-repeat-end="">
        <td colspan="3">{{person.gender}}</td>
      </tr>
    </tbody>

First function ng-if="person.expanded" ng-click="person.expanded = false" works, but second not. Is it through multiple ng-repeat-end? Plunker : http://plnkr.co/edit/g1t4pludTTIAJYKTToCK?p=preview + on left side works, on right not. Thanks for answers in advance!

1 Answer 1

1

You have to put only one ng-repeat-end at the last tr element

updated code :

<tbody>
  <tr ng-repeat-start="person in people">
    <td>
      <button ng-if="person.expanded" ng-click="person.expanded = false">-</button>
      <button ng-if="!person.expanded" ng-click="person.expanded = true">+</button>
    </td>

    <td>{{person.name}}</td>
    <td>{{person.gender}}</td>
    <td>
      <button ng-if="person.expanding" ng-click="person.expanding = false">-</button>
      <button ng-if="!person.expanding" ng-click="person.expanding = true">+</button>
    </td>
  </tr>
  <tr ng-if="person.expanded">
    <td colspan="3">{{person.details}}</td>
  </tr>
  <tr ng-if="person.expanding" ng-repeat-end="">
    <td colspan="3">{{person.gender}}</td>
  </tr>
</tbody>
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.