I am currently working on my Angular app using the Materialize Library. I'm facing an issue where I want to assign a random class name to each tag so that the background color is different for each one.
<ul class="inline-list" ng-repeat="feature in features">
<li class="chip" ng-class="getColor()">{{feature}}</li>
</ul>
Here's my controller:
function ProjectsController($scope) {
$scope.features = ['React', 'Redux', 'Firebase'];
const colorClass = ['pink lighten-3', 'indigo lighten-2', 'lime accent-1',
'amber accent-2','grey darken-2', 'deep-orange darken-1', 'green accent-2',
'teal', 'purple', 'red darken-1'];
$scope.getColor = () => {
return colorClass[Math.floor(Math.random()*10)]
}
}
However, I'm encountering an error in the browser:
angular.js:10633 Error: [$rootScope:infdig]
I would appreciate any hints or clues on how to solve this problem.