post.$save();
$window.location.href = 'success.html';
app.controller('FormCtrl', function($scope, $filter, $window, getData, Post, randomString) {
// Get all posts
$scope.posts = Post.query();
// Form data for creating a new post with ng-model
$scope.postData = {};
$scope.$on('updateImage', function() {
$scope.postData.attachment = getData.image;
});
$scope.postData.userid = "Mango Farmer";
$scope.postData.uuid = randomString(32);
$scope.$on('updateGPS', function() {
$scope.postData.gps = getData.gps;
});
$scope.postData.devicedate = $filter('date')(new Date(),'yyyy-MM-dd HH:mm:ss');
$scope.newPost = function() {
var post = new Post($scope.postData);
console.log(post);
post.$save();
$window.location.href = 'success.html';
}
});
成功響應應該是:
post.$save().then(function(response) {
$window.location.href = 'success.html';
});
我敢肯定,這就是正確的。試試看,讓我知道。
謝謝!完美工作! – shredMER