angular2-letter-avatar
Version:
letter avatar is angular2 directive. It will generate avatar based on given text
63 lines (59 loc) • 2.17 kB
text/typescript
import {Component, OnChanges, ChangeDetectionStrategy, NgZone, ApplicationRef} from '@angular/core';
import {LetterAvatarDirective} from '../directives/letter-avatar.directive';
export class AppComponent implements OnChanges {
constructor(private ngZone: NgZone, private ref: ApplicationRef) {
}
public avatarDataSquare: any = {
size: 150,
// background: '#F39C12', // by default it will produce dynamic colors
fontColor: '#FFFFFF',
border: "2px solid #d3d3d3",
isSquare: true,
text: "Rajan Gunasekaran"
};
public avatarDataCircle1: any = {
size: 100,
// background: '#F39C12', // by default it will produce dynamic colors
fontColor: '#FFFFFF',
border: "2px solid #d3d3d3",
isSquare: false,
text: "Rajan Gunasekaran"
};
public avatarDataCircle2: any = {
size: 100,
// background: '#F39C12', // by default it will produce dynamic colors
fontColor: '#FFFFFF',
border: "2px solid #d3d3d3",
isSquare: false,
text: "Siva",
fixedColor:true
};
size = 100;
text = 'Siva';
ngOnChanges(change) {
console.log(change);
}
change() {
this.ngZone.run(() => {
this.avatarDataCircle2 = {
size: this.size,
// background: '#F39C12', // by default it will produce dynamic colors
fontColor: '#FFFFFF',
border: "2px solid #d3d3d3",
isSquare: false,
text: this.text,
fixedColor:true
};
})
}
}