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
Post a Comment