首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Angular 6聊天应用程序中集成Emoji

在Angular 6聊天应用程序中集成Emoji
EN

Stack Overflow用户
提问于 2019-03-07 14:13:33
回答 1查看 1.4K关注 0票数 2

我正在尝试使用名为ngx- Emoji -mart的库将emoji集成到我的Angular 6聊天应用程序中

下面是我的代码

我的模板文件- chat.component.html

代码语言:javascript
复制
<div #emojiDiv class="emojiInput" contentEditable="true" [innerHTML]="input"  >
</div>
<emoji-mart (emojiClick)="addEmoji($event)"></emoji-mart> 

我的组件类- chat.component.ts

代码语言:javascript
复制
import { Component, OnInit, ViewEncapsulation, ElementRef } from '@angular/core';

@Component({
  selector: 'app-chat',
  templateUrl: './chat.component.html',
  styleUrls: ['./chat.component.css'],
  encapsulation: ViewEncapsulation.None,
})


export class ChatComponent implements OnInit {

constructor() { }
ngOnInit() {

}

public addEmoji(){
    if(this.input) {
      this.input = this.input + "<ngx-emoji emoji='point_up'></ngx-emoji>";
     } else{
      this.input = "<ngx-emoji emoji='point_up'></ngx-emoji>";
     }
 }
}

而不是附加到div。

还有什么我需要补充的吗?提前感谢

EN

回答 1

Stack Overflow用户

发布于 2020-06-22 11:38:07

代码语言:javascript
复制
npm install @ctrl/ngx-emoji-mart

import { PickerModule } from '@ctrl/ngx-emoji-mart'

在angular.json中添加样式表:

代码语言:javascript
复制
"styles": [
          "src/styles.css",
          "../node_modules/@ctrl/ngx-emoji-mart/picker.css"
        ],

添加此app.module.ts:

代码语言:javascript
复制
@NgModule({
...,
imports:      [ ..., PickerModule, ... ],
...
})

在app.component.html中添加此内容

代码语言:javascript
复制
<emoji-mart title="Pick your emoji…" emoji="point_up"></emoji-mart> 

你好!!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55037167

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档