JSFiddle - React, Tailwind, and code Playground

by jteve code

HTML

<body ng-app='fruitApp'>
		<div ng-controller='fruitTableController'>
			<table>
				<tr ng-repeat='fruit in fruits' ng-click='selectFruit($index)' 
				ng-class='{selected : $index==selectedRow}'>
					<td>{{fruit.name}}</td>
					<td>{{fruit.price}}</td>
				</tr>
			</table>			
		</div>
	</body>

CSS

.selected{
				background-color: lightgreen;
			}

JavaScript

var app = angular.module('fruitApp',[]);

			function __fruitTableController($scope){
				$scope.fruits=[
					{name:'banana',price:'5000'},
					{name:'apple',price:'3000'},
					{name:'tomato',price:'4000'},
				];
				$scope.selectFruit = function(index){
					$scope.selectedRow= index;
				}

			}

			app.controller('fruitTableController',__fruitTableController);