diff --git a/src/avatar/avatar.component.html b/src/avatar/avatar.component.html
index fafecb23247..4695efc0d76 100644
--- a/src/avatar/avatar.component.html
+++ b/src/avatar/avatar.component.html
@@ -1,13 +1,21 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
\ No newline at end of file
+
+
+
+
diff --git a/src/avatar/avatar.component.ts b/src/avatar/avatar.component.ts
index 228cee364d5..a1714fcb170 100644
--- a/src/avatar/avatar.component.ts
+++ b/src/avatar/avatar.component.ts
@@ -4,9 +4,11 @@ import {
AfterViewInit,
Component,
ElementRef,
+ HostBinding,
Input,
NgModule,
Renderer2,
+ TemplateRef,
ViewChild,
ViewEncapsulation
} from "@angular/core";
@@ -35,8 +37,19 @@ export class IgxAvatarComponent implements AfterViewInit, AfterContentChecked {
public sizeEnum = Size;
public roleDescription: string;
+ @ViewChild("imageTemplate", { read: TemplateRef }) protected imageTemplate: TemplateRef;
+ @ViewChild("initialsTemplate", { read: TemplateRef }) protected initialsTemplate: TemplateRef;
+ @ViewChild("iconTemplate", { read: TemplateRef }) protected iconTemplate: TemplateRef;
+
protected fontName = "Titillium Web";
+ @HostBinding("attr.aria-label") private ariaLabel = "avatar";
+ @HostBinding("attr.role") private role = "img";
+ @HostBinding("attr.class")
+ get classes() {
+ return "igx-avatar igx-avatar--" + this.size;
+ }
+
private _size: string;
private _bgColor: string;
private _icon = "android";
@@ -73,6 +86,18 @@ export class IgxAvatarComponent implements AfterViewInit, AfterContentChecked {
return this.roundShape.toUpperCase() === "TRUE" ? true : false;
}
+ get template() {
+ if (this.src) {
+ return this.imageTemplate;
+ }
+
+ if (this.initials) {
+ return this.initialsTemplate;
+ }
+
+ return this.iconTemplate;
+ }
+
@Input()
public get icon(): string {
return this._icon;