【发布时间】:2016-12-05 12:21:14
【问题描述】:
我必须将xml response to json 转换为angularjs。我正在使用一个以 xml 格式提供响应的 Rest api,但 angularjs 在通过 $http.get() 检索时需要 json 响应。
以下是我如何在 angularjs 中使用 rest api。
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope,$http) {
$http({
method: 'GET',
url: "https://some-url?fieldList=field1,field2"
}).then(function(response) {
$scope.obj=response.data.records;},function(response){});}
});
</scripts>
如何将 xml 响应转换为 json 并将其作为输入提供给某个变量 $scope.obj?
【问题讨论】:
标签: javascript angularjs json xml