Created
September 20, 2018 06:21
-
-
Save Sampath-Lokuge/6e58e478d67ff8066ed14be1db00a712 to your computer and use it in GitHub Desktop.
Angular app ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
import { SiteNotificationService } from '../services/common/sitenotification.service'; | |
import { Router } from '@angular/router'; | |
import { Location } from '@angular/common'; | |
@Component({ | |
templateUrl: './playlist.component.html' | |
}) | |
export class PlaylistComponent implements OnInit { | |
playlist: any; | |
constructor( | |
public location: Location, | |
private router: Router, | |
private notificationService: SiteNotificationService | |
) { } | |
ngOnInit(): void { | |
this.playlist = JSON.parse(localStorage.getItem('clicked-playlist')); | |
if (!this.playlist) | |
return this.notificationService.showError('Couldn\'t load playlist, please go back and try again.'); | |
} | |
parseTime(seconds) { | |
if (!isNaN(seconds)) { | |
let minute = Math.floor(seconds / 60); | |
let second = (seconds - Math.floor(seconds / 60) * 60); | |
return ((minute < 10) ? ('0' + minute) : minute) + ':' + ((second < 10) ? ('0' + second) : second); | |
} else { | |
return "00:00"; | |
} | |
} | |
videoDetailsPage(video) { | |
localStorage.setItem('clicked-video', btoa(JSON.stringify(video))); | |
this.router.navigate(['video-details']); | |
} | |
openSearchPage() { | |
this.router.navigate(['video-search']); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment