2015-07-11 54 views
0

我在尝试使用运动ID来过滤运动Feed。但json提要是基于@属性的提要。如何使用ng-filter Json [@attributes]使用Angularjs?

JSON源

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 }"> 

所以PLE帮助我。

高级谢谢。

回答

0

也许$scope.sports = sports;应改为$scope.sports = response;

然后在ng-repeat你会得到sport属性与sport['@attributes']

+0

感谢您的时间!当我使用sport ['@ attributes']时,我在'_item_ in _collection_'中出现了错误:[ngRepeat:iidexp]'_item_'应该是一个标识符或'(_key_,_value_)'表达式,但'sport [ '@属性']”。' –