Directive
app.directive('mcAvatar', function() {
return {
restrict: 'E',
scope: {
width: '=width',
src: '@src'
},
templateUrl: 'directives/mc-avatar/mc-avatar.html',
link: function (scope, element, attrs) {
console.log(element[0])
}
};
});
Template
<img width="{{ width }}" src="{{ src }}" alt="" class="mc-avatar-round">
Usage
<mc-avatar width="50" src="http://lorempixel.com/320/320/cats"></mc-avatar>
The element
inside the link function in the directive returns :
<mc-avatar width="50" src="http://lorempixel.com/320/320/cats" class="ng-isolate-scope">
<img width="50" src="http://lorempixel.com/320/320/cats" alt="" class="mc-avatar-round">
</mc-avatar>
which gives the the context to mg-avatar
only. How do I access the img
element here so that I could use bind
functions?