Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/421.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
javascript TypeError:Math.random不是chrome上的函数_Javascript_Angularjs_Google Chrome_Math_Random - Fatal编程技术网

javascript TypeError:Math.random不是chrome上的函数

javascript TypeError:Math.random不是chrome上的函数,javascript,angularjs,google-chrome,math,random,Javascript,Angularjs,Google Chrome,Math,Random,我在AngularJS代码中使用Math.random()函数 $scope.runFull = function () { var rand; do { rand = Math.random(); ... } while ($scope.cond < 5400); // 90 minutes }; $scope.runFull(); $scope.runFull=函数(){ var rand; 做{ rand=Math.

我在AngularJS代码中使用Math.random()函数

$scope.runFull = function () {
var rand;
    do {
        rand = Math.random();
        ...
    } while ($scope.cond < 5400); // 90 minutes         
};
$scope.runFull();
$scope.runFull=函数(){
var rand;
做{
rand=Math.random();
...
}而($scope.cond<5400);//90分钟
};
$scope.runFull();
我的Chrome控制台返回javascript类型错误:Math.random不是函数


我把Math放在watcher中,发现Math.abs、Math.acos、Math….、Math.random、Math….

Math或Math.random被覆盖。在第一行代码中运行Math.random(),看看会发生什么

我的错误是:angular.module('xxxxx app') .controller('FullController',函数($scope,$interval,xxxxService,yyyyyservice,…,数学,主体){

是的,非常感谢大家,我有一个名为“Math”的angularjs服务


解决方案:我将我的“数学”服务重命名为“数学”并且我可以使用Math.random():)

你能创建一个我们可以重现错误的例子吗?这个链接可能会对你有所帮助。sushmit.patil,我已经阅读了这篇文章,但我仍然有这个问题。没有给出解决方案确保你没有定义
Math
变量。
var Math={};Math.random()=>未捕获类型错误:Math.random不是函数
如果我重写了行:rand=Math.random();我的代码是OK在项目开始时运行该行。您可能正在加载一个有bug的包。我将AngulasJS与一些服务一起使用,我可以切换顺序。当我们使用AngulasJS时,永远不要创建服务名称“Math”。