angularjs http post,带angularjs和GAE

2024-05-19 15:05:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要一个小修理。我只需要使用angularjs将我的数据(注释)发布到数据存储(GAE)中,但这还没有实现。下面的angularjs“post”或html有什么问题?在

角度:

$scope.addComment = function() {

        var form_comment = $scope.formFields.comment

        var payload = {
            comment: form_comment
        }

        $http({
            method: 'POST',
            url: '/exp'
        }).then(function successCallback(response) {

            $scope.comments.push(payload);


        }, function errorCallback(response) {

        });

    };

HTML:

^{pr2}$

PYTHON:

^{3}$

Tags: 数据formresponsevarhtmlcommentfunctionpost
1条回答
网友
1楼 · 发布于 2024-05-19 15:05:04

post方法的签名如下:

post(url, data, [config]); 

所以你还应该包括有效载荷。试试这样的方法:

^{pr2}$

另外,在promise的then()方法中,您应该发送对该方法的引用:

      .then(function(response) {
          $scope.comments.push(payload);
      }, function(response) {

      });

相关问题 更多 >