JSFiddle - React, Tailwind, and code Playground

by simpulton

HTML

<div ng-app ng-controller="MainCtrl">
    <h2>Master</h2>    
    <p ng-repeat="item in items" ng-click="setCurrentIndex($index)" 
        ng-class="{active: $index == currentIndex}">{{item}}</p>

    <h2>Slave</h2>
    <p ng-repeat="item in items" 
        ng-class="{active: $index == currentIndex}">{{item}}</p>
    
</div>

CSS

.active {
    color: red;
}

JavaScript

var MainCtrl = function($scope) {
    $scope.currentIndex = 2; 
    $scope.items = ['one', 'two', 'three', 'four', 'five'];
    
    $scope.setCurrentIndex = function(index) {
        $scope.currentIndex = index;
    };
};