Angular Directive Element Attributes

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

HTML

<div ng-app="demo" ng-controller='DemoCtrl'>
    <p ng-repeat='image in images'>
        <img ng-src='{{image}}' alt="" img-transform="" />
    </p>
</div>

JavaScript

var app = angular.module('demo', []);

app.directive('imgTransform', function () {
    return {
        retrict: 'A',
        controller: function ($scope, $element, $attrs) {
            $attrs.$set('ngSrc', 'someOtherValue');
        },
        link: function (scope, elem, attrs) {
            attrs.$observe('ngSrc', function (val) {
                console.log(val);
            });
        }
    };
});

function DemoCtrl($scope) {   
    $scope.images = [
        'http://lorempixel.com/100/100/sports',
        'http://lorempixel.com/100/100/cats',
        'http://lorempixel.com/100/100/abstract'
    ];
}