ng2-avatar
TypeScript icon, indicating that this package has built-in type declarations

2.3.1 • Public • Published

ng2-avatar

npm version, Build Status Coverage Status dependency Status devDependency Status license

Angular Avatar (ng2-avatar) is a simple and lightweight avatar component

Demo

View all the directives in action at https://snics.github.io/ng2-avatar

Dependencies

  • Angular (requires Angular 2 or higher, tested with 2.0.0)

Installation

Install above dependencies via npm.

Now install ng2-avatar via:

npm install --save ng2-avatar

SystemJS

Note:If you are using SystemJS, you should adjust your configuration to point to the UMD bundle. In your systemjs config file, map needs to tell the System loader where to look for ng2-avatar:

map: {
  'ng2-avatar': 'node_modules/ng2-avatar/bundles/ng2-avatar.umd.js',
}

Once installed you need to import the main module:

import { AvatarModule } from 'ng2-avatar';

The only remaining part is to list the imported module in your application module. The exact method will be slightly different for the root (top-level) module for which you should end up with the code similar to (notice AvatarModule.forRoot()):

import { AvatarModule } from 'ng2-avatar';
 
@NgModule({
  declarations: [
    AppComponent, 
    ...
  ],
  imports: [
    AvatarModule.forRoot(), 
    ...
  ],  
  bootstrap: [AppComponent]
})
export class AppModule {
}

Other modules in your application can simply import AvatarModule:

import { AvatarModule } from 'ng2-avatar';
 
@NgModule({
  declarations: [OtherComponent, ...],
  imports: [LibModule, ...], 
})
export class OtherModule {
}

Usage

  <avatar [email]="email" [displayType]="'circle'"></avatar>
  <input type="email" [(ngModel)]="email">

Configuration

configuration option type default description
email String none This email is for generated the initials letters or get the picture from Gravatar API (required)
name string none This name is for generated the initials letters (required)
size number 100 Is the size of the image and avatar
background string Random color The background colors for the letter's avatar
displayType string circle none, circle, rounded
letter string ? These are the default letter
defaultProtocol string null specifies a protocol or uses protocol-agnostic gravatar url when empty

License

Copyright (c) 2017 Nico Swiatecki. Licensed under the MIT License (MIT) - Initial work - Snics

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

/ng2-avatar/

    Package Sidebar

    Install

    npm i ng2-avatar

    Weekly Downloads

    69

    Version

    2.3.1

    License

    MIT

    Unpacked Size

    186 kB

    Total Files

    23

    Last publish

    Collaborators

    • snic