$ scope.msgs.push不是n。$ scope.send_msg中的函数

时间:2016-07-28 09:33:49

标签: angularjs node.js

我尝试创建聊天应用程序必须私下将消息从user-1推送到user-2。我创建了$scope.msgs=[];变量来存储消息。这段代码不是我的代码,我从here获取了源代码。

这里是发送消息的发送消息功能。

                $scope.msgs.push({ 
                    msg:$scope.send_text,
                    from_id:$scope.uid,
                    to_id:$scope.send_to_userinfo.id,
                    timestamp:Math.floor(new Date() / 1000)
                });
                $scope.send_text="";
                $scope.self.scrollDiv();
                console.log($scope.msgs);
            }           

1 个答案:

答案 0 :(得分:0)

而不是这一个---> $scope.msgs=[];,请尝试var msgs=[];。希望它能起作用。