【发布时间】:2017-11-28 22:40:27
【问题描述】:
我在 sendMessage 函数中的 chat.services.ts 中遇到错误。 我正在尝试做一个异步管道,但它没有从我的 chat-message.model.ts 中读取对象
这是我在 chat-message.model.ts 中的代码:
export class ChatMessage {
$key?: string;
email?: string;
userName?: string;
message?: string;
timeSent?: Date = new Date();
}
这也是我在 chat.services.ts 中的代码:
sendMessage(msg: string){
const timestamp = this.getTimeStamp();
const email = 'test@example.com';
this.chatMessages = this.getMessage();
this.chatMessages.push({
message: msg,
timeSent: timestamp,
userName: 'test-user',
email: email });
getMessage(): AngularFireList<ChatMessage[]> {
// Query to create Message Feed Binding
console.log('Calling getMessages()!')
return this.db.list('messages')
}
我觉得这很明显,但代码在我看来确实不错。
我感觉这可能与 $key 有关?
【问题讨论】:
-
getMessages长什么样子? -
编辑了问题,getMessages() 工作正常,就像我在通过我的 firebase 数据库之前发送消息时一样
标签: angular typescript