0

hope someone can help me with this question.

I have an entity which contains a start time (let's say 15 o'clock) and an end time (let's say 16 o'clock). It also contains the date (let's say today^^).

So my query returns all data of today, but I only want to show the data between 15 and 16 o'clock.

Do I need to set a $timeout for each object? Or is it possible to automatically call a method called shouldShowData which used in ng-show?

Basically I have a list of objects and want to show single object just on a specific time of the day.

EDIT Imagine that the screen is shown in a public place and displays different news at different time (morning news, evening news, ...) and should automatically update when the specific news should be displayed based on it's start and end time. It can't be updated manually with a refresh button for example.

Great to here from you :)

7
  • Maybe you could have a list of objects with an isVisible property i.e. List of myObj { DateToUse = x, isVisible = false }, loop though the list setting the flag and use ng-if or ng-show in the ui. I have done something similar for a complex scenario. Alternatively, the filters (docs.angularjs.org/api/ng/filter/filter) are very powerful, but i cannot find a good example to match your request. Sorry it's not a direct answer. If you are setting data in the code behind, you might need to use digest to get it to update the ui. Commented Sep 25, 2014 at 10:38
  • Why not to send already filtered data from the server?
    – Marian Ban
    Commented Sep 25, 2014 at 10:42
  • 2
    if you are ng-repeat-ing over this list, then a $filter would work nicely. Commented Sep 25, 2014 at 10:50
  • @MajoB: But the server has to sent the actualized data, let's say every minute, because the user want's an actualized list... Commented Sep 25, 2014 at 10:54
  • @DavinTryon: Does the filter actualize the list? So let's say the data is visible until 16 o'clock and I was loading the data at 15:55, starring 5 minutes at the screen, doing nothing, will it remove the object from the list at 16 o'clock? Commented Sep 25, 2014 at 10:56

1 Answer 1

0

I have found similar problem and solution for it here

All you need is to wrap this into $filter and use on ng-repeat.

2
  • Yes, with Angular data binding, it will update automatically. Commented Sep 26, 2014 at 14:36
  • Now i had time to test it and it works like a charm! Thank you very much :) Commented Dec 2, 2014 at 9:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.