【问题标题】:Failed to send the message by testing the tutorial in angularjs-chat在angularjs-chat中测试教程发送消息失败
【发布时间】:2017-10-13 22:55:17
【问题描述】:

我收到此错误

TypeError: self.rooms[setup.to].publish 不是函数

发送消息时。我已经有 pubnub 中的密钥,我应该怎么做才能让它工作?我的 Angular 版本是 1.6.6。

// Send Messages
$scope.send = function() {
    Messages.send({
        data: $scope.textbox
    });
};

【问题讨论】:

    标签: javascript angularjs web pubnub


    【解决方案1】:

    我不知道你是否使用表格但尝试这种方式:

       <form name="form" novalidate="true" ng-submit="send()">
    
        $scope.send = function () {
            if ($scope.form.$valid) {
                var data = $scope.textbox;
                $scope.textbox = null;
                $scope.messages.push(data);//of push or send depend did proto
            }
        }
    

    【讨论】:

    • 我有这个表格&lt;div ng-app="BasicChat"&gt; &lt;div ng-controller="chat"&gt; &lt;div ng-repeat="message in messages"&gt; &lt;strong&gt;:&lt;/strong&gt; &lt;span&gt;&lt;/span&gt; &lt;/div&gt; &lt;form ng-submit="send()"&gt; &lt;input ng-model="textbox"&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt;
    • 我编辑了表单对于检查值的要求,我在循环重复时通过消息更改消息
    猜你喜欢
    • 1970-01-01
    • 2013-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多