Could anyone please help me on getting unique values for Math.random()? I want to have random number in each 3x3 cell, but so far I'm manage to get only THIS result (same number in all 5 cells).
script.js:
var app = angular.module("myApp", []);
app.controller("RandomCtrl", function ($scope){
$scope.showRandom = function () {
return Random;
};
});
var Random = Math.floor(Math.random() * 9 + 1);
index.html:
<div ng-app="myApp">
<div ng-controller="RandomCtrl">
<table>
<tr>
<td>{{showRandom()}}</td>
<td>{{showRandom()}}</td>
<td>{{showRandom()}}</td>
</tr>
<tr>
<td>{{showRandom()}}</td>
<td>{{showRandom()}}</td>
<td>{{showRandom()}}</td>
</tr>
<tr>
<td>{{showRandom()}}</td>
<td>{{showRandom()}}</td>
<td>{{showRandom()}}</td>
</tr>
</table>
</div>
$scope.showRandom = function () { return Math.floor(Math.random() * 9 + 1); };instead.