import { WindowRefService } from './../../services/window-ref.service'; import { Component, HostListener, OnInit } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { VideoServices, VideoService } from '../home/video-services'; import { DateTime } from "luxon"; @Component({ selector: 'video-services-component', templateUrl: './video-services.component.html', styleUrls: ['./video-services.component.css'], }) export class VideoServicesComponent implements OnInit { public loading: boolean = true; public services: VideoService[]; constructor(private http: HttpClient){ } ngOnInit(){ this.http.get('assets/json/videoServices.json') .subscribe(res => { this.services = res.videos.filter(v => v.isReady === true); this.loading = false; }); } showVideo(index: number) { this.services.forEach(s => { (s).show = false; }); (this.services[index]).show = true; } getTitle(index: number): string { const title = this.services[index].title; const dte = DateTime.fromISO(this.services[index].date, {zone: 'America/Denver'}) return title + ' | ' + dte.toLocaleString(DateTime.DATETIME_MED); } }