Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.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/7/image/5.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
Angularjs 角度1:图像赢得';不要过一会儿再装弹_Angularjs_Image - Fatal编程技术网

Angularjs 角度1:图像赢得';不要过一会儿再装弹

Angularjs 角度1:图像赢得';不要过一会儿再装弹,angularjs,image,Angularjs,Image,在我的HTML中,我有以下img链接: imgURL在控制器中设置: $scope.imgURL = 'img/img_'+$scope.img.id+'.jpg; 在第一次更改中,它工作得非常完美,但过了一段时间,图像不再显示 我读了一篇文章,尝试了几种“解决方案”,比如添加一个随机值的参数,这样它就可以强制重新加载,但没有成功。我将url记录在控制台中,看到它在变化,所以这不是重点 是什么原因导致图像在一段时间后不出现,它看起来如此随机。。? 非常感谢您的回答,我非常绝望:-/我不知道您

在我的HTML中,我有以下img链接:

imgURL在控制器中设置:

$scope.imgURL = 'img/img_'+$scope.img.id+'.jpg;
在第一次更改中,它工作得非常完美,但过了一段时间,图像不再显示

我读了一篇文章,尝试了几种“解决方案”,比如添加一个随机值的参数,这样它就可以强制重新加载,但没有成功。我将url记录在控制台中,看到它在变化,所以这不是重点

是什么原因导致图像在一段时间后不出现,它看起来如此随机。。?
非常感谢您的回答,我非常绝望:-/

我不知道您的HTML结构或代码,但对于AngularJS,我会使用类似的方式进行图像源旋转。它很简单,也很有效:

angular.module('myApp',[])
.controller('mainController',函数($scope,$interval){
变量图像=[
'https://placehold.it/350x150',
'https://placehold.it/450x250',
'https://placehold.it/250x250'
];
var i=0;
$scope.image=图像[i];
$interval(函数(){
i++;
if(i


请向我们展示您的代码并与我们分享。也许您在模板中使用了一次性绑定,比如{{::imgURL}?