这是我的HTML
View C
我的js控制器功能
<input type="text" name="message" ng-model="senderMessage">
<button type="submit" ng-click="sendSenderMessage(1,5,senderMessage)">
click me
</button>
,其中
$scope.sendSenderMessage = function (bsid, srid, message) {
$scope.senderMessage = message;
$http.post(url + 'c_chat/sendSenderMessageJson', {
bsid: bsid,
srid: srid,
message: $scope.senderMessage
})
.success(function (data) {
console.log(data);
$scope.chatForm();
$scope.startChat(srid);
});
}
我的问题是我无法重置$ scope.senderMessage空白
答案 0 :(得分:1)
你应该提供.error(函数(数据))来发布请求,因为如果发生错误,那么$ scope.chatForm将不会被调用,$ scope.senderMessage将保持不变。
或者你应该这样做
wp core update
答案 1 :(得分:0)
$scope.sendSenderMessage = function (bsid, srid, message) {
$scope.senderMessage = message;
$http.post(url + 'c_chat/sendSenderMessageJson', {
bsid: bsid,
srid: srid,
message: $scope.senderMessage
})
.success(function (data) {
console.log(data);
$scope.chatForm();
$scope.startChat(srid);
});
where $scope.chatForm = function() {
$scope.senderMessage = "";
$timeout(angular.noop); //use
//try let me know again u are getting same problem.
}
angular.noop是一个空函数,当您需要将某个函数作为参数传递时,可以将其用作占位符。