1
我试图将XML数据绑定到AngularJS中的变量。将解析的XML数据绑定到AngularJS变量
的数据从我的服务返回的是XML
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">
<Response>
<Firstname>Johanna</Firstname>
</Response></string>
然后我用x2js解析XML和得到这个返回:
var jsonResponse = x2js.xml_str2json(response);
最后,我要绑定名字到$ scope.firstname
这是我需要帮助的地方。我不知道该怎么做绑定价值。 什么香港专业教育学院的尝试:
$scope.firstname = jsonResponse.Response.Firstname;
> TypeError: Cannot read property 'Firstname' of undefined
$scope.firstname = jsonResponse.Object.Object.toString.__text.Response.Firstname
> TypeError: Cannot read property 'Object' of undefined
我用尽了一堆不同的组合,试图去名字,但没有正常工作。我要么得到上述错误或未定义的消息。
我在做什么错?请帮忙。
真棒!谢谢 – JCom09