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........

I want to filter the array using status ,i used filter:{status:"POI"} ,but it throwing error

My json

  [
       {
           "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"
       }
    ]
5
  • May try filter:{d.status:"POI"} Commented Aug 8, 2013 at 9:31
  • i tried ,but not working Commented Aug 8, 2013 at 9:33
  • 2
    using filter:{"status":"POI"} works, jsfiddle.net/DotDotDot/S2KhB Commented Aug 8, 2013 at 9:35
  • But in my directive ,its not working Commented Aug 8, 2013 at 9:40
  • have you correctly escaped your " in your template ? In your code it seems that you have unescaped "" around POI, which leads to an error, but it's not a filtering issue Commented Aug 8, 2013 at 9:49

1 Answer 1

2

it will be easier here than in the comments, but your issue is just linked to an escaping problem

you can see your directive here, working : http://jsfiddle.net/DotDotDot/S2KhB/1/

the issue :

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

ou can see that you used " everywhere which was understood by you browser as

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

so you had an error, the only thing I did was using escaped '

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

and it seems to work =)

Have fun

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.