我尝试像刷新值字段一样。但标题和正文值正确更新。
$scope.refreshTime = function(){
$scope.time = new Date();
};
$scope.changeMessage = function(key) {
$scope.refreshTime();
console.log($scope.time);
var child = $scope.messages.$child(key);
child.$set({title: $scope.title, body: $scope.msg, time: $scope.time});
}
$scope.addMessage = function(e) {
$scope.refreshTime();
$scope.messages.$add({title: $scope.title, body: $scope.msg, time: $scope.time });
}
答案 0 :(得分:1)
$ scope.time是一个对象。试试这个:
$scope.messages.$add({title: $scope.title, body: $scope.msg, time: $scope.time.valueOf()});