2014-01-05 61 views
0

我嘗試刷新值字段。但標題和正文值正確更新。設置後的AngularFire miss字段

$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

數據類型有問題。 '時間:41010101'運作良好。但是'time:$ scope.time'有什麼問題? – YYY

回答

1

$ scope.time是一個對象。試試這個:

$scope.messages.$add({title: $scope.title, body: $scope.msg, time: $scope.time.valueOf()});