0.2.0 • Published 9 years ago
ng2-emoji v0.2.0
ng2-emoji
Installation
To install this library, run:
$ npm install ng2-emoji --saveDemo Example
See the live example (Angular4 project) here
Usage
VERY IMPORTANT
In one of your css/scss files. include these styles:
.emoji{
display:inline-block;
}In your Angular AppModule:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
// Import your library
import { Ng2EmojiModule } from 'ng2-emoji';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
// Include the awesome
Ng2EmojiModule.forRoot()
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }In your index.html:
<link href="./node_modules/ng2-emoji/css/ng2-emoji.css" rel="stylesheet">OR if using angular-cli.json, use:
"apps": [
{
...
"styles": [
"styles.css",
"../node_modules/ng2-emoji/css/ng2-emoji.css"
],
...
]In your component where you want to use ng2-emoji, just use:
<div class="message-container" [innerHTML]="myMessageString | emojis">
</div>where the model myMessageString inside your @Component will be:
...
export class MyComponent {
public messageString: String = "";
constructor() {
this.myMessageString = 'Hello, how are you? :smile: It was fun at the bowling game the other day :joy:';
}
}Development
Clone the repository:
git clone https://github.com/AhsanAyaz/ng2-emojiInstall dependencies
npm installTo build the library:
npm run buildTo generate the spritesheet :
gulp spriteTo lint all *.ts files:
npm run lintRun example locally
Perform the following steps to serve the Angular example locally. Navigate to http://localhost:4200 after that.
cd example
npm install
ng serveContribution
Feel free to contribute to this repo by:
- Adding Examples
- Resolving open issues
Thanks to Juan Carlos for the amazing Angular example
License
MIT © Ahsan Ayaz