角度推对象到数组返回不起作用

I'm trying to push returned data from socket-io into my messages array but it says:

错误TypeError:this.messages.push不是函数

messages: any[] = [];

constructor(...){...}

ngOnInit() {
 this.socket.fromEvent('message').subscribe((message: any) => {
   console.log('from socket', message.msg.message); // sample data provided in down
   this.messages.push(message.msg.message);
 });
}

sample data

from socket 
    {id: 51, group_id: 1, user_id: 1, note: "wrwgwwg", deleted_at: null, …}
        created_at: "2020-05-18T08:19:59.000000Z"
        deleted_at: null
        group_id: 1
        id: 51
        note: "wrwgwwg"
        updated_at: "2020-05-18T08:19:59.000000Z"
        user: {id: 1, name: "Sam", username: "admin", phone: "081200000001", photo: null, …}
        user_id: 1
        __proto__: Object

任何的想法?

评论