javascript - How to filter an array using angular js -
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 filter array using status ,i used filter:{status:"poi"}
,but 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" } ]
it easier here in comments, issue linked escaping problem
you can see directive here, working : http://jsfiddle.net/dotdotdot/s2khb/1/
the issue :
data-ng-repeat="d in model.dossier | filter:{status:"poi"}"
ou can see used " everywhere understood browser
data-ng-repeat="d in model.dossier | filter:{status:" +another attribute ignored
so had error, thing did using escaped '
data-ng-repeat="d in data | filter:{status:\'poi\'}"
and seems work =)
have fun
Comments
Post a Comment