我是 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/