English 中文(简体)
Nebular Chat UI
原标题:Nebular Chat UI component

I have issue with chat UI component style it show as follow enter image description here

我的守则

<nb-layout>
    <nb-layout-column>
        <nb-chat title="Chat APP">
            <nb-chat-message *ngFor="let msg of messages"
                             [type]="msg.type"
                             [message]="msg.text"
                             [reply]="msg.reply"
                             [sender]="msg.name"
                             [date]="msg.date"
                             [quote]="msg.quote"
                             [avatar]="msg.avatar">
            </nb-chat-message>
        
            <nb-chat-form (send)="sendMessage($event)" [dropFiles]="false">
            </nb-chat-form>
        </nb-chat>
    </nb-layout-column> </nb-layout>

聊天室。

import { Component, OnInit } from  @angular/core ;
import { ChatService } from  src/app/Services/chat.service ;

@Component({
  selector:  app-chat-room ,
  templateUrl:  ./chat-room.component.html ,
  styleUrls: [ ./chat-room.component.scss ],
})
export class ChatRoomComponent implements OnInit {
  messages: any[] = [];

  constructor(protected chatService: ChatService) {
    this.chatService.getMessage().subscribe((data: any) => {
      console.log(data);
      this.messages.push(data);
    });
  }

  ngOnInit(): void {}

  sendMessage(event: any) {
    var payload = {
      text: event.message,
      date: new Date(),
      reply: true,
      type:  text ,
      name:  Jonh Doe ,
      avatar:  https://i.gifer.com/no.gif ,
    };
    this.messages.push(payload);

    this.chatService.sendMessage(event.message);
  }
}

The style is not right and the other screen it shows only the circles without any text I am not able to find any solution can anyone help with this ?

问题回答

这是因为你没有推动对信息的反应。

const response = await 
this.chatService.sendMessage(event.message).toPromise();
const botReply = response[ reply ];
if (botReply) {
   setTimeout(() => { this.messages.push(botReply); }, 500);
}




相关问题
Angular matSort not working on Date column by desc

Trying to sort the material table with date column , date format is MM/DD/YYYY ,h:mm A , order of date is not by latest date and time. Anything which i missed from the below stackblitz code. https:/...

热门标签