我正在尝试对收件箱进行回复,我认为这就像发送邮件一样简单。我在电子邮件中输入了参数,而不是$scope.messageTo
和$scope.messageFrom
。
有人知道我的代码中的错误在哪里吗?我不知道是什么原因导致错误“字符串不是函数”,并且没有给我任何变量名。
// Reply to message
// Console error in browser: TypeError: string is not a function
$scope.reply = function () {
var msg = $scope.reply;
console.log('Replying...');
$scope.message = {
read: false,
sender: {
id: $scope.user.user._id,
name: $scope.user.user.user.first + " " + $scope.user.user.user.last,
user: $scope.user.user.user.user
},
message: msg,
};
Inbox.sendNewMessage($scope.message, 'My Name', '[email protected]', '[email protected]');
};
更新:我认为这与调用$ scope.reply函数本身有关。如果我删除$ scope.reply中的所有代码并添加一个简单的console.log('Replying');,它也会给我同样的错误。这是触发回复功能的代码:
<button data-dismiss="modal" data-toggle="modal" href="#direct-messages" ng-click="reply();">Send Reply</button>
这是我的ng-model =“ reply”
<textarea Placeholder="Write a reply..." ng-model="reply"></textarea>
替换为:
Inbox.sendNewMessage($scope.message, 'My Name', '[email protected]', '[email protected]');
有了这个:
Inbox.sendNewMessage($scope.message.message, 'My Name', '[email protected]', '[email protected]');
并为变量使用另一个名称,因为它与函数名称相同:
var msg = $scope.replyMsg;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句