When you provide an option to select an item in list of items then you must show the difference between selected items and un-selected items. To show this difference, changing in the background color or text color of selected item is necessary. The user must recognize the items that are select-able, To implement this feature we need to change the background-color or text-color on mouse over. Lets do this with example.


Here selectedItem class will give background color to selected item
.item {
  border:1px solid #ccc;

.hoverItem:hover {

.selectedItem {


record.classes holds the array of classes.  You can learn about adding and removing classes from here
<html ng-app="" ng-controller="myCtrl">
<div ng-click="selectItem($index)" ng-class="record.classes" ng-repeat="record in records track by $index">


The logic is simple. When user clicks on an item we will add selected class and remove hover class
function myCtrl($scope) {
    // initialize data
    $scope.records = [];
    for(var i=0;i<5;i++) {
           value: "record "+i,
           classes : ["item", "hoverItem"]

    // when user selected item
    $scope.selectItem = function(index) {
       for(var i=0;i<$scope.records.length;i++) {
          if(index === i) {
          } else {

1 comment:

  1. Tom Cruise has played the character of a perfect spy trying to clear his record in the movie Knight and Day released in 2010. On the request of the customers and fans of the actor we are bringing out Mission Impossible Leather Jacket



Follow this blog by Email

Popular Posts