I am working with a json file that contains my data
[{"id":"349","title":"event 1"},{"id":"350","title":"event 2"},{"id":"351","title":"event 3"}]
Users have the ability to save events to local storage, which are then stored in an array
$storage.myEvents = ["349","350"]
On the webpage, I display all events using the following code;
<ion-item class="item-icon-right item-brown" ui-sref="detail({id: event.id})" ng-repeat="event in events track by event.id ">
<h2 class="positive"><b>{{event.title}}</b></h2>
</ion-item>
I want to only show the events that the user has stored in $storage.myEvents
, but my filter is not working
<ion-item class="item-icon-right item-brown" ui-sref="detail({id: event.id})"
ng-repeat="event in events track by $index | filter: {id: $storage.myEvents }">
This results in the error
Error: filter:notarray Expected array but received: 0
, when I check the local storage, I find
localStorage["ngStorage-myEvents"]
"["349","350"]"
Even if I change the filter to
filter: {id: JSON.parse($storage.myEvents)}
The error persists...
How can I resolve this issue?