Get class in array
Description
The following code shows how to use ng click event to change style.
Example
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<style type='text/css'>
.red {<!-- ww w.jav a 2 s .com-->
background-color: red;
}
.green {
background-color: green;
}
.blue {
background-color: blue;
}
</style>
</head>
<body>
<div ng-app="myApp" ng-controller="MainCtrl">
<div ng-init="index=0; classes=['red', 'green', 'blue']"
ng-click="index = index + 1"
ng-class="classes[index % classes.length]">Test 1 2 3.</div>
</div>
<script type='text/javascript'>
var app = angular.module('myApp', []);
app.controller('MainCtrl', function($scope) {});
</script>
</body>
</html>