import { AvatarService } from 'ng-avatar'
import { Component } from '@angular/core'
@Component({
selector: 'my-app',
template: `
<img alt="" src="" id="avatar-image">
<button type="button" (click)="setImage()">Get Avatar</button>
`
})
export class AppComponent
{
constructor(private avatar:AvatarService) {}
setImage()
{
let initials:string = this.avatar.Avatar('initials', 'John Doe'),
gravatar:string = this.avatar.Avatar('gravatar', 'John Doe', 'john@johndoe.com');
document.getElementById('avatar-image').setAttribute('src', initials);
}
}