1

Hi I have following table in ng-repeat

<div ng-repeat ="item in items">
   <span>{{item.name}}></span>
   <span>{{item.age}}></span>
</div>

what I want to do is Each row with mouse over is highlighted and clickable to passing the item to further process.

Please let me know how i can achieve this

1 Answer 1

5
  • To highlight on mouseover you could use the :hover CSS Selector
  • To pass item to further process, you could use ngclick

CSS

.hoverme:hover
{
background-color:yellow;
}
.clicked
{
background-color:green;
}

JS

<div class="hoverme" ng-repeat ="item in items" ng-click="doSomething(item)" ng-class="{clicked:rowClicked==item}">
   <span>{{item.name}}></span>
   <span>{{item.age}}></span>
</div>

Update

Example plunker

Sign up to request clarification or add additional context in comments.

2 Comments

This works fine except that once I click the row color doesnt stay yellow. Please let me know how the background color stays same untill another row is clicked. Thanks
not sure why select.js needs to exist for this plunker example, but this is hands down the best solution for highlighting table rows. I've seen answers with 114 ups that were nothing compared to this. Thank you.

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.