1
我需要將XML內的HTML字符串發送到POST REST服務。在angularjs中創建html和xml內容的最簡單方法
目前我使用字符串連接創建XML的和HTML的像下面,
var html = " <div style='some style'>... append model data from the response of some services ... </div> ";
html += " <div> ... append model data from the response of some services ...</div> ";
var xml = "<?xml version='1.0' encoding='utf-8'?>";
xml += "<root><data>";
xml += "<![CDATA["+ html +"]]>";
xml += "</data></root>";
return $http.post(url,xml,{headers : {'Content-Type': 'application/atom+xml'}});
它看起來非常難看作爲真正的HTML內容是巨大的。除了字符串連接之外,哪種方法最簡單?
您可以將html代碼存儲在html文件中,並使用'$ http.get' – Christoph