A database table contains the following values:
"295fc51f6b02d01d54a808938df736ed" : {
"author" : "James Iva",
"authorID" : "JBvLC3tCYCgFeIpKjGtSwBJ2scu1",
"geometry" : {
"latitude" : 29.4241219,
"longitude" : -98.49362819999999
},
"listDate" : 1482331706209,
"openHours" : {
"Friday" : {
"closeTime" : "17:00",
"openTime" : "09:00",
"status" : true
},
"Monday" : {
"closeTime" : "17:08",
"openTime" : "09:00",
"status" : true
},
"Saturday" : {
"closeTime" : "17:00",
"openTime" : "09:00",
"status" : true
},
"Sunday" : {
"closeTime" : "17:00",
"openTime" : "10:00",
"status" : true
},
"Thursday" : {
"closeTime" : "17:00",
"openTime" : "09:21",
"status" : true
},
"Tuesday" : {
"closeTime" : "17:00",
"openTime" : "04:00",
"status" : false
},
"Wednesday" : {
"closeTime" : "17:00",
"openTime" : "10:00",
"status" : false
}
},
"pPhone" : "no_phone",
"placeAdd" : "San Antonio, TX, USA",
"placeCat" : "Education"
}
}
The task at hand is to determine if the place is currently open (status is true) and display a message like the following in the template:
IT'S THURSDAY 4:12PM - WE'RE OPEN!
How can this be achieved using angular2?
Below is the code used to subscribe and retrieve data from a service:
ngOnInit() {
this.sub = this.route.params.subscribe(params => {
this.id = params['id'];
let str = params['string'];
// Retrieve Pet with Id route param
this._placesService.findPetById(this.id).subscribe(place => {
this.place = place; //Here should be the opening data!
});
});
}