Note that there are some explanatory texts on larger screens.

plurals
  1. POangular js '?' in ng-src causes infinite loop
    primarykey
    data
    text
    <p>I am trying to get a way around IE getting images from cache while using AngularJS</p> <p>I have this following code</p> <pre><code>&lt;img ng-src="./individuals/image/{{team._id}}/{{member._id}}{{getRandom()}}" &gt; </code></pre> <p>In the controller </p> <pre><code>$scope.getRandom=function(){ return "?ran="+new Date().getTime()+""; } </code></pre> <p>When I run, I get this error</p> <pre><code>Error: 10 $digest() iterations reached. Aborting! Watchers fired in the last 5 iterations: [["fn: function (a){\n\"use strict\";\ntry{for(var b=0,c=q,g;b&lt;c;b++){if(typeof(g=l[b])==\"function\")g=g(a),g==null||g==s?g=\"\":typeof g!=\"string\"&amp;&amp;(g=da(g));B[b]=g}return B.join(\"\")}catch(f){d(Error(\"Error while interpolating: \"+e+\"\\n\"+f.toString()))}}; newVal: \"./individuals/image/51c209ead8b8d863ad69de97/51c209ead8b8d863ad69de65?ran=1371757784485\"; oldVal: \"./individuals/image/51c209ead8b8d863ad69de97/51c209ead8b8d863ad69de65?ran=1371757784457\"","fn: function (a){\n\"use strict\";\ntry{for(var b=0,c=q,g;b&lt;c;b++){if(typeof(g=l[b])==\"function\")g=g(a),g==null||g==s?g=\"\":typeof g!=\"string\"&amp;&amp;(g=da(g));B[b]=g}return B.join(\"\")}catch(f){d(Error(\"Error while interpolating: \"+e+\"\\n\"+f.toString()))}}; newVal: \"./individuals/image/51c209ead8b8d863ad69de97/51c209ead8b8d863ad69dec9?ran=1371757784487\"; oldVal: \"./individuals/image/51c209ead8b8d863ad69de97/51c209ead8b8d863ad69dec9?ran=1371757784459\"","fn: function (a){\n\"use strict\";\ntry{for(var b=0,c=q,g;b&lt;c;b++){if(typeof(g=l[b])==\"function\")g=g(a),g==null||g==s?g=\"\":typeof g!=\"string\"&amp;&amp;(g=da(g));B[b]=g}return B.join(\"\")}catch(f){d(Error(\"Error while interpolating: \"+e+\"\\n\"+f.toString()))}}; newVal: \"./individuals/image/51c209ead8b8d863ad6 </code></pre> <p>If I remove the <code>{{getRandom()}}</code> it works fine.</p> <p>Please help.. Thanks in advance</p> <p><em><strong>UPDATE: Please find below the changes to controller that fixed the issue. Thanks to the answer from Liviu T.</em></strong></p> <pre><code>$scope.lastMillis = new Date().getTime(); $scope.getRandom=function(){ var curMillis = new Date().getTime(); if (curMillis-$scope.lastMillis&gt;5000) { $scope.lastMillis = curMillis; } return "?ran="+$scope.lastMillis; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload