angularjs $http post 无法正常工作

标签 angularjs go

我是 angularjs 的新手。我试图通过 $http post 将一些数据发布到服务器。我的代码可以到达服务器,但没有传递数据。我在后端使用 golang。我在这里犯了什么错误?

completeCampaign.controller('campaignCtrl', ['$scope', '$http', function(scope, http) {
    var Msg = "hai";
    http.post("/server_url",Msg).then(function(response) {
        console.log(response);
    });
}]);

去代码:

func (c *CarController) TestFunction() {
    msg := c.GetString("Msg")
    fmt.Println("Message is: ", msg)
}

输出:

Message is:

最佳答案

使用 $ 符号:

$http.post("/server_url",Msg).then(function(response) {
    console.log(response);
});

关于angularjs $http post 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38591141/

相关文章:

rest - gRPC 服务器如何调用 REST 端点

bash - 安装go并设置路径后,仍然出现错误

javascript - "push-model"在 RxJS/Immutable.js/AngularJS 等上下文中的含义

javascript - AngularJS:ngTouch 300ms 延迟

javascript - 尝试关闭 Ionic Loader 时出错

go - 如何在 Go 和 yaml 包的 API v3 中生成配置文件时对注释进行编码

javascript - 如何禁用 Angular 数据表中数据的初始排序?

javascript - 查询 dom 中的 angularjs 对象

go - 从 Go 中的 StdoutPipe() 读取卡住

go - 发生异常时继续执行循环