import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-chatter',
  templateUrl: './chatter.page.html',
  styleUrls: ['./chatter.page.scss'],
})
export class ChatterPage implements OnInit {

  constructor() { }

  ngOnInit() {
  }
  messages: any[] = [
    { sender: 'user', text: 'Hello', avatar: 'assets/user-avatar.png' },
    { sender: 'other', text: 'Hi there!', avatar: 'assets/other-avatar.png' }
  ];
  newMessage: string = '';

  messagesother: any[] = [
    { sender: 'other', text: 'Hi there!', avatar: 'assets/other-avatar.png' }
  ];
  newMessageother: string = '';
  sendMessage() {
    if (this.newMessage.trim() !== '') {
      this.messages.push({ sender: 'user', text: this.newMessage, avatar: 'assets/user-avatar.png' });
      this.newMessage = ''; // 清空输入框
    }
  }
}