2013-08-08 2 views
0
나는 상태를 사용하여 배열을 필터링 할
angular.module('harbinger'). 
     directive('dossierList', function() { 
      return { 
       restrict:"EAC", 
       template:'<div class="Dossier-details" data-ng-repeat="d in model.dossier | filter:{status:"POI"}">'+ 
       '<p>'+ 
       '<strong>'+'Dossier ID'+'</strong>:'+ 
       '<small>'+'{{ d.title }}'+'</small>'+ 
       '</p>'+ 
       '</div>', 
etc........ 

, 난, filter:{status:"POI"}을 사용을 사용하여 배열을 필터링 할 수 있지만 내 JSON어떻게 각도 JS

오류를 던지는

[ 
     { 
      "id": "1", 
      "status": "POI", 
      "title": "West Nile virus - US", 
      "dossierId": "000455" 
     }, 
     { 
      "id": "2", 
      "status": "I", 
      "title": "influenza", 
      "dossierId": "000455" 
     }, 
     { 
      "id": "4", 
      "status": "P", 
      "title": "corona virus", 
      "dossierId": "000455" 
     } 
    ] 
+0

필터 시도 : {d.status : "POI"} – tschiela

+0

시도했지만 작동하지 않았습니다 – Prashobh

+2

필터 사용 : { "status": "POI"} http://jsfiddle.net/DotDotDot/S2KhB/ – DotDotDot

답변

2

이 여기보다 더 쉬울 것이다 의견에 있지만 문제는 지금 막 떠오르는 문제에 연결되어 있습니다

여기에 지침을 볼 수 있습니다 : http://jsfiddle.net/DotDotDot/S2KhB/1/

문제 :

data-ng-repeat="d in model.dossier | filter:{status:"POI"}" 

ou는 당신이

data-ng-repeat="d in model.dossier | filter:{status:" +another attribute ignored 
그래서

당신이, 내가 한 유일한 것은 '오류 탈출 사용 된했던대로 브라우저 당신에게 이해 된 모든 곳에서 "사용 된 것을 알 수 있습니다

data-ng-repeat="d in data | filter:{status:\'POI\'}" 

작동하는 것 같다 =)

재밌게 보내십시오