Load specific elements in JSON file


#1

I have a JSON file with 365 messages, a message for each day of the year.

-How do I load on the homepage Yesterday’s, Today’s, and Tomorrow’s message title based on device date? User will then click on title and go to that message page.
-How to use a date picker to pick a particular date of the message?

JSON file is something like this:

{
  "messages": [
    {
    "id": "1",
    "date": xxxxxxxx,
    "message": " sample message1.",
    "thumb": "assets/img/message1.jpg",
    "title": "sample title1"
  },
    {
    "id": "2",
    "date": xxxxxxx,
    "message": " sample message2.",
    "thumb": "assets/img/message2.jpg",
    "title": "sample title2"
  },

Thanks in advance…


#2

hi to get the data from json or any api source you from.
you can easily get your device date by creating new instance of data angularjs syntax
and then used carbon date to get yesterday.current.tomorrow when the same time.
that will do the works


#3

Pinoyprogs thx for your reply.
I’m a complete newbie. Would you have some sample code to demonstrate?

I assume the json file will be loaded within ngOnInit() in the home.ts page, and then query the json file by the dates? How do you do that with angularjs syntax?