I am currently working with a directive called ngAvatar:
app.directive('ngAvatar', function() {
return {
restrict: 'E',
replace: true,
template: '<img class="avatar-medium" ng-src="{{url}}" />',
link: function(scope, elem, attrs) {
console.log(attrs);
var aType = attrs.avatarType;
var aId = attrs.avatarId;
console.log("Type: "+ aType);
console.log("Character ID:"+ aId);
var baseUrl = "http://api-character.com/";
switch(aType){
case "character":
scope.url = baseUrl + "Character/"+aId+"_256.jpg";
}
}
}
});
However, I am encountering an issue where the directive does not seem to recognize the avatar_id within it. Despite logging the attributes:
console.log("Type: "+ aType);
console.log("Character ID:"+ aId);
In my view, I have implemented the directive as follows:
<ng-avatar avatar_type="character" avatar_id="{{character.character_id}}"></ng-avatar>
When checking the Chrome Console for output, the avatar_id appears blank even though the attribute is present in the attrs
. It just doesn't display in the directive code.
Chrome Console:
If anyone has any insights on why this isn't working correctly, your help would be greatly appreciated.
Thank you