├── demo
├── src
│ ├── assets
│ │ ├── .gitkeep
│ │ ├── .npmignore
│ │ └── logo.svg
│ ├── app
│ │ ├── app.component.scss
│ │ ├── shared
│ │ │ ├── index.ts
│ │ │ ├── content-wrapper
│ │ │ │ ├── content-wrapper.component.scss
│ │ │ │ ├── content-wrapper.component.html
│ │ │ │ ├── content-wrapper.component.ts
│ │ │ │ └── content-wrapper.component.spec.ts
│ │ │ ├── header
│ │ │ │ ├── header.component.scss
│ │ │ │ ├── header.component.ts
│ │ │ │ ├── header.component.html
│ │ │ │ └── header.component.spec.ts
│ │ │ ├── footer
│ │ │ │ ├── footer.component.scss
│ │ │ │ ├── footer.component.ts
│ │ │ │ ├── footer.component.html
│ │ │ │ └── footer.component.spec.ts
│ │ │ └── shared.module.ts
│ │ ├── app.component.html
│ │ ├── home
│ │ │ ├── home.component.scss
│ │ │ ├── home-routing.module.ts
│ │ │ ├── home.module.ts
│ │ │ ├── home.component.ts
│ │ │ ├── home.component.spec.ts
│ │ │ └── home.component.html
│ │ ├── getting-started
│ │ │ ├── getting-started-routing.module.ts
│ │ │ ├── getting-started.module.ts
│ │ │ ├── getting-started.component.ts
│ │ │ ├── getting-started.component.spec.ts
│ │ │ ├── getting-started.component.scss
│ │ │ └── getting-started.component.html
│ │ ├── app-routing.module.ts
│ │ ├── app.component.ts
│ │ ├── app.server.module.ts
│ │ ├── app.module.ts
│ │ └── app.component.spec.ts
│ ├── testing
│ │ ├── index.ts
│ │ └── router-stubs.ts
│ ├── main.server.ts
│ ├── favicon.ico
│ ├── environments
│ │ ├── environment.hmr.ts
│ │ ├── environment.prod.ts
│ │ └── environment.ts
│ ├── typings.d.ts
│ ├── _variables.scss
│ ├── tsconfig.spec.json
│ ├── tsconfig.server.json
│ ├── tsconfig.app.json
│ ├── hmr.ts
│ ├── main.ts
│ ├── styles.scss
│ ├── test.ts
│ ├── index.html
│ └── polyfills.ts
├── static.paths.ts
├── proxy.conf.json
├── e2e
│ ├── app.po.ts
│ ├── tsconfig.e2e.json
│ └── app.e2e-spec.ts
├── .editorconfig
├── tsconfig.json
├── .gitignore
├── protractor.conf.js
├── karma.conf.js
├── README.md
├── webpack.server.config.js
├── prerender.ts
├── server.ts
├── package.json
├── .angular-cli.json
└── tslint.json
├── src
├── index.ts
├── module
│ ├── component
│ │ ├── avatar.component.scss
│ │ ├── avatar.component.html
│ │ ├── avatar.component.ts
│ │ └── avatar.component.spec.ts
│ ├── avatar.module.ts
│ └── Md5.ts
├── tsconfig.spec.json
└── tsconfig.lib.json
├── .babelrc
├── karma.conf.js
├── webpack.config.js
├── .editorconfig
├── tsconfig.json
├── .travis.yml
├── .gitignore
├── config
├── karma-test-shim.js
├── helpers.js
├── karma.conf.js
└── webpack.test.js
├── .yo-rc.json
├── LICENSE
├── .github
└── ISSUE_TEMPLATE.md
├── tslint.json
├── CHANGELOG.md
├── package.json
├── README.MD
└── gulpfile.js
/demo/src/assets/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/demo/src/assets/.npmignore:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/demo/src/app/app.component.scss:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/demo/src/testing/index.ts:
--------------------------------------------------------------------------------
1 | export * from './router-stubs';
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './module/avatar.module';
2 |
--------------------------------------------------------------------------------
/demo/src/app/shared/index.ts:
--------------------------------------------------------------------------------
1 | export * from './shared.module';
--------------------------------------------------------------------------------
/demo/src/app/shared/content-wrapper/content-wrapper.component.scss:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | "es2015"
4 | ]
5 | }
6 |
7 |
--------------------------------------------------------------------------------
/karma.conf.js:
--------------------------------------------------------------------------------
1 | module.exports = require('./config/karma.conf.js');
2 |
--------------------------------------------------------------------------------
/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = require('./config/webpack.test.js');
2 |
--------------------------------------------------------------------------------
/demo/src/main.server.ts:
--------------------------------------------------------------------------------
1 | export { AppServerModule } from './app/app.server.module';
2 |
--------------------------------------------------------------------------------
/demo/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/snics/ng2-avatar/HEAD/demo/src/favicon.ico
--------------------------------------------------------------------------------
/demo/static.paths.ts:
--------------------------------------------------------------------------------
1 | export const ROUTES = [
2 | '/',
3 | '/getting-started/',
4 | ];
5 |
--------------------------------------------------------------------------------
/demo/src/app/shared/header/header.component.scss:
--------------------------------------------------------------------------------
1 | .navbar {
2 | background: hsla(0,0%,100%,.95)
3 | }
4 |
--------------------------------------------------------------------------------
/demo/src/environments/environment.hmr.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: false,
3 | hmr: true
4 | };
5 |
--------------------------------------------------------------------------------
/demo/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true,
3 | hmr: false
4 | };
5 |
--------------------------------------------------------------------------------
/demo/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
Angular2+ Avatar (ng2-avatar) is a simple and lightweight avatar component
10 |Scroll down to see it in action!
11 | 15 |Install above dependencies via npm.
17 |Now install ng2-avatar via:
>npm install --save ng2-avatar20 | 21 | 22 |
24 |29 | 30 |Note:If you are using
28 |SystemJS, you should adjust your configuration to point to 25 | the UMD bundle. 26 | In your systemjs config file,mapneeds to tell the System loader where to look forng2-avatar: 27 |
31 | 32 |map:'ng2-avatar': 'node_modules/ng2-avatar/bundles/ng2-avatar.umd.js'
Once installed you need to import the main module:
33 | 34 |35 | 36 |;
The only remaining part is to list the imported module in your application module. The exact method will be
37 | slightly
38 | different for the root (top-level) module for which you should end up with the code similar to (notice AvatarModule.forRoot()):
39 |
42 | 43 |;@
Other modules in your application can simply import AvatarModule :
46 | 47 |;@
49 | 50 |<avatar [email]="email" [displayType]="'circle'"></avatar><input type="email" [(ngModel)]="email">
| configuration option | 55 |type | 56 |default | 57 |description | 58 |
|---|---|---|---|
| String | 64 |none | 65 |This email is for generated the initials letters or get the picture from Gravatar API 66 | (required) 67 | | 68 ||
| name | 71 |string | 72 |none | 73 |This name is for generated the initials letters (required) | 74 |
| size | 77 |number | 78 |100 | 79 |Is the size of the image and avatar | 80 |
| background | 83 |string | 84 |Random color | 85 |The background colors for the letter's avatar | 86 |
| displayType | 89 |string | 90 |circle | 91 |none, circle, rounded | 92 |
| letter | 95 |string | 96 |? | 97 |These are the default letter | 98 |
| defaultProtocol | 101 |string | 102 |null | 103 |specifies a protocol or uses protocol-agnostic gravatar url when empty | 104 |