I hava a directive "avatar", which takes a 'user' object and displays an image of the user.
This works fine.
Now I have another directive 'user', which displays the name of given 'user' object and includes withing its template the directive.
This works.. THE FIRST TIME.
when I update the 'user' object, only the name changes, the image (avatar) does NOT change.
My Problem : How can I make it work ?
Avatar directive :
(link function : if user object does have a 'ext' property, it calculates an image path ('src'), otherwise it displays a standard template.jpeg)
directive('avatarSmall', function() {
return {
restrict: "E",
replace: true,
templateUrl: "scripts/directives/avatar/small.html",
link: function(scope, element, attrs) {
var r = "images/avatars/";
var ext = scope.user.ext;
r += ext != undefined && ext.length >= 3 ? scope.user.ID + "." + ext : "template.jpeg";
scope.src = r;
},
scope: {
user: '='
}
}
})
avatar template :
<div class="circle-wrapper-small">
<img class="circle-img-small"
ng-src="{{src}}">
</div>
user directive :
directive('user', function($compile) {
return {
restrict: "E",
replace: true,
templateUrl: "scripts/directives/user/template.html",
scope: {
user: '='
}
}
})
user template :
<div>
<div class="media-left">
<avatar-small user="user" />
</div>
<div class="media-body">
<h4 class="media-heading">{{user.name}} {{user.surname}}</h4>
</h5>
</div>
</div>