传输两个有角度的数组

Transmit two arrays with angular

本文关键字:数组 两个 传输      更新时间:2023-09-26

我想将两个带有角度的数组传输到我的play framework(2.4)应用程序。

这就是我所拥有的。inP 和 outP 是数组

$http({
        url: $scope.appUrl + 'networkInsertJson',
        method: "POST",
        data: angular.toJson($scope.inP, $scope.outP),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
        }
})

如何传输两个有角度的数组?

这应该适合你。

$http({
    url: $scope.appUrl + 'networkInsertJson',
    method: "POST",
    data: angular.toJson({ in: $scope.inP, out:  $scope.outP}),
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
    }
 })

angular.toJson(obj, pretty); 需要两个参数,一个转换为 Json,另一个是一个标志,如果它是否应该美化它。

在此处查看文档:https://docs.angularjs.org/api/ng/function/angular.toJson

如果要发送两个值,请将它们包装在一个对象中。这样,您可以同时发送两者。