0

I have an html table, <tbody> of it is generated with angular ng-repeat. Here is my html:

<tbody ng-repeat="car in carList | filter:tableFilter">
    <tr>
        <td><a target="_blank" href="{{car.carLink}}">{{car.name}}</a></td>
        <td>{{car.review}}</td>
        <td>{{car.rating}}</td>
        <td>{{car.fiveStarPercent}}</td>
        <td>{{car.recommended}}</td>
        <td>{{car.price}}</td>
    </tr>
</tbody>

Here is the part of my table in the browser:

enter image description here

With AngularJS, is it possible to do so, if you click on some table row, the rest of the table shifts a bit and in the middle some information about specific row is showing up? Here is an expected output:

enter image description here

If it is possible then can I do this?

1
  • You can always append a td with the styling that is displayed in the image after the click event Commented Sep 12, 2014 at 12:55

1 Answer 1

3

You could do something like this:

<tbody>
    <tr ng-repeat-start="car in carList | filter:tableFilter" ng-click="car.showDetails = !car.showDetails">
        <td><a target="_blank" href="{{car.carLink}}">{{car.name}}</a></td>
        <td>{{car.review}}</td>
        <td>{{car.rating}}</td>
        <td>{{car.fiveStarPercent}}</td>
        <td>{{car.recommended}}</td>
        <td>{{car.price}}</td>
    </tr>
    <tr ng-repeat-end ng-show="car.showDetails">
        Some details...
    </tr>
</tbody>
Sign up to request clarification or add additional context in comments.

2 Comments

There is one interesting issue, in your solution when you press on some row and then press on another, the first row doesn't close. Do you know how to fix that?
Instead of storing showDetails on the individual car objects you could store an activeDetailsIndex variable on your controller and just set it to the index of the car that you want to show.

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.