大家好我试图通过角度设置rss feed我得到这个错误“不允许在转发器中使用重复项。使用'track by'表达式来指定唯一键.Repeater:feed in FeedSrc,Duplicate key:string:t,重复值:t “。请查看下面的代码,告诉我哪里出错了,或者你是否可以指出我如何设置它的正确方向。
这是我的角度代码
var Search = angular.module('searchApp', ['ngMaterial', 'ngMessages']);
Search.controller("FeedCtrl", ['$scope','FeedService', function ($scope,Feed) {
// $scope.loadButonText="Load";
$scope.feedSrc= "http://rss.cnn.com/rss/edition_sport.rss";
$scope.loadFeed=function(e){
Feed.parseFeed($scope.feedSrc).then(function(res){
$scope.loadButonText=angular.element(e.target).text();
$scope.feeds=res.data.responseData.feed.entries;
});
}
}]);
Search.factory('FeedService', ['$http', function($http){
return {
parseFeed : function(url) {
return $http.jsonp('//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=50&callback=JSON_CALLBACK&q='+ encodeURIComponent(url));
}
}
}]);
这是我的HTML代码
<md-content class="md-padding">
<h1 class="md-display-2">Articles</h1>
<md-list ng-controller="FeedCtrl">
<md-list-item class="md-3-line" ng-repeat="feed in feedSrc" style="margin-bottom:20px;">
<img ng-src="{{feed.image}}" class="face" style="padding-right:20px;">
<div class="md-list-item-text">
<h3>{{feed.title}}</h3>
<h4>{{feed.pubDate}}</h4>
<p>{{feed.teaser}}</p>
</div>
<md-button class="md-accent">Read more</md-button>
<md-divider ng-if="!$last"></md-divider>
</md-list-item>
</md-list>
</md-content>