JavaScript Generate same random number each time when controller loaded generate same random numbers python,generate same random numbers matlab,

I have Icon with me and one scope.id and I am assigning different color code each time with Icon . Suppose

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);
    }   
});

HTML

<div ng-repeat='id in id'>
    <span style="background-color:rgb({{$scope.Icon[$index]}},255,255)">{{id}}</span>
</div>

so I want that when I will reload my page again it should get same color again but now it will return different color because of Math.random()

Please suggest me or guide me because I am new.

Answer:1

The implementation selects the initial seed to the random number generation algorithm; it cannot be chosen or reset by the user

From JavaScript reference.

Use pregenerated array of numbers.

Answer:2

I am using the Bootstrap CSS and JS libraries in my site and the following code: $(function(){ $("#nav-login-btn").click(function(){ if($("#togglesection").not(":visible")) { $("#nav-...

I am using the Bootstrap CSS and JS libraries in my site and the following code: $(function(){ $("#nav-login-btn").click(function(){ if($("#togglesection").not(":visible")) { $("#nav-...

i would like to add comfirmationbox in durandal.js i wrote following to code , but it is not returning Yes or NO define(['services/logger', 'durandal/plugins/router', 'durandal/app'], function (...

i would like to add comfirmationbox in durandal.js i wrote following to code , but it is not returning Yes or NO define(['services/logger', 'durandal/plugins/router', 'durandal/app'], function (...

I'm trying to do a CORS on ie9 using ie9proxy.html: <!DOCTYPE HTML> <script src="https://apiurl/Content/xdomain.min.js"></script> "xdomain: Timeout waiting on iframe socket" ...

I'm trying to do a CORS on ie9 using ie9proxy.html: <!DOCTYPE HTML> <script src="https://apiurl/Content/xdomain.min.js"></script> "xdomain: Timeout waiting on iframe socket" ...

i have a class called .content , this content has an attribute called .data-time, i want to hide all element where it has .content class with setTimeout() function, anybody can help me? HTML code : &...

i have a class called .content , this content has an attribute called .data-time, i want to hide all element where it has .content class with setTimeout() function, anybody can help me? HTML code : &...

  1. multiple settimeout jquery
  2. settimeout jquery multiple function