How to change the class separately for each element? (Angular)


I have a demo when on click it changes the class back and worth, but I can't figure it out how to change them separately.

Here's a demo for better explanation:

I could add similar line of code to the js with class2, class3 etc, but the problem is that this class will be repeated a lot of times. If you have any ideas on how to fix this problem that would be great. Thank you in advance

$scope.changeClass = function(){
        if ($scope.class === "rotated")
            $scope.class = "rotated2";
            $scope.class = "rotated";

Just change class to be an array and then pass each index:

$scope.changeClass = function(i){
    if ($scope.class[i] === "red")
        $scope.class[i] = "blue";
        $scope.class[i] = "red";

Fiddle here