0
我使用下面的代碼設法將xml響應轉換爲角度1中的json格式。但我怎麼能使用類似的代碼在angular2,angular2 transformRequest xml轉換爲json轉換的用法
var xml = function() {
$http.get("./app/sampleXML.xml",
{
transformResponse: function (cnv) {
var x2js = new X2JS();
var aftCnv = x2js.xml_str2json(cnv);
return aftCnv;
}
})
.success(function (response) {
console.log(response);
});
}
Angular2:
getXml() {
this.http.get('../../jsonConfig/sampleXML.xml')
.map(response => response.text())
.subscribe(data => {
if(data) {
console.log(data);
}
});
}