I currently have an Icon and a unique scope.id, where I assign a different color code to the Icon each time. This is what I have:
angular.module('myAppp').controller('myCtrl',function(){
scope.id=[0,1,2,3];
//generate random number
$scope.Icon=[];
for(i=0;i<scope.id.length;i++) {
var ran= Math.floor( Math.random()*255)+$scope.id[i];
$scope.Icon.push(ran);
}
});
Here's the HTML:
<div ng-repeat='id in id'>
<span style="background-color:rgb({{$scope.Icon[$index]}},255,255)">{{id}}</span>
</div>
Whenever I reload the page, I want the colors to remain the same, but due to the use of Math.random(), they change. Can someone provide guidance as I'm new to this?