我正在使用本教程: http ://rabidgadfly.com/2013/02/angular-and-xml-no-problem/
为了启动 XML 的应用程序,当我设置外部 xml(Feedburner)时告诉我我无权访问,有人知道它可能是什么吗?
HTML:
<section ng-controller="AppController" class="container-podcastapp">
<ul>
<li ng-repeat="guitar in dataSet">
<div class="resultwrapper">
<h2>{{item.title}}</h2>
</div>
</li>
</ul>
</section>
javascript:
angular.module('myApp.service',[]).
factory('DataSource', ['$http',function($http){
return {
get: function(file,callback,transform){
$http.get(
file,
{transformResponse:transform}
).
success(function(data, status) {
console.log("Request succeeded");
callback(data);
}).
error(function(data, status) {
console.log("Request failed " + status);
});
}
};
}]);
angular.module('myApp',['myApp.service']);
var AppController = function($scope,DataSource) {
var SOURCE_FILE = "http://rss.cnn.com/services/podcasting/ac360/rss.xml";
xmlTransform = function(data) {
console.log("transform data");
var x2js = new X2JS();
var json = x2js.xml_str2json( data );
return json.item;
};
setData = function(data) {
$scope.dataSet = data;
};
DataSource.get(SOURCE_FILE,setData,xmlTransform);
};