如何使用Angularjs使用ng-filter Json [@attributes]?

时间:2015-07-11 05:14:12

标签: json angularjs

我试图通过使用体育ID过滤运动饲料。但是json feed是基于@attribute的feed。

Json Feed

series: [
{
  @attributes: {
   id: "cdf590b4-0206-45b0-9122-20eae46a2b27",
   name: "Pakistan tour of Sri Lanka, 2015",
   year: "2015"
  },
  match: [
  {},
  {},
  {},
  {}
 ],
 comment: []
},
{
 @attributes: {
  id: "324e971e-2044-4fa6-bdb2-0c47c99da64e",
  name: "South Africa tour of Bangladesh, 2015",
  year: "2015"
 },
 match: [
  {},
  {},
  {},
  {}
 ],
 comment: []
},

我的控制器

--So this my controller code.--
$http.get('http://example.com/cricket.php').then(function(response) {
    $scope.sports = sports;
    $scope.whichsports = $state.params.id;
}

此我的视图过滤器代码

<ion-item ng-repeat="sport in sports | filter: { id : whichsports }">

所以请帮帮我。

提前谢谢。

1 个答案:

答案 0 :(得分:0)

可能$scope.sports = sports;应该是$scope.sports = response;

然后在ng-repeat中,您将获得sport的{​​{1}}属性