angularjs - Obtaining element attributes within a custom directive used within ng-repeat -


This is making me a bit nuts I need to read the source of an image within a custom attribute:

  app.directive ('imgTransform', function () {return} (copy: 'a', link: function (scope, Elem, attrs) {console.log (elem.attr ('ng -src '))}}}});   

This works fine when used:

  & lt; img ng -src = 'http: //lorempixel.com/100/100/technics' alt = "" img-change = "" />   

However, this ng - Do not work inside:

  & lt; p Ng-repeat = 'image in images' & gt; img-ng-src = '{{picture}}' alt = "" img-transform = "" />  < / Code>  

The given value is {{image}} . How can I get the actual value

attrs :
  console.log (attrs.ngSrc);   

Wired:

The reason for this can be that ng-repeat uses the original DOM as a template and regenerates it for each iteration. For some reason (unclear), you are reading the feature of the template. Although this explanation can be very wrong ...

However, since the angle gives you an API to access the properties, it will still be safe to go with it.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -