ng2-emojify
Version:
An angular 2 module to support built-in and custom emoji
23 lines (18 loc) • 645 B
text/typescript
import {Pipe, PipeTransform} from '@angular/core';
import {CustomEmotionService} from "./services/custom-emotion.service";
({
name: 'emojify'
})
export class EmojifyPipe implements PipeTransform {
emotions: any;
constructor(private customEmotionService: CustomEmotionService) {
this.emotions = this.customEmotionService.GetEmotions();
}
transform(value: any, args?: any): any {
for (let emotion of this.emotions) {
let re = new RegExp(':' + emotion.emojiId + ':', 'ig');
value = value.replace(re, `<img src= ${emotion.emojiUrl} class="emogi-image" title= ${emotion.title}>`);
}
return value;
}
}