1 import { Component, EventEmitter, Input, Output } from '@angular/core';
3 import { SortField } from '../shared';
6 selector: 'my-video-sort',
7 templateUrl: './video-sort.component.html'
10 export class VideoSortComponent {
11 @Output() sort = new EventEmitter<any>();
13 @Input() currentSort: SortField;
15 sortChoices: { [ P in SortField ]: string } = {
17 '-name': 'Name - Desc',
18 'duration': 'Duration - Asc',
19 '-duration': 'Duration - Desc',
20 'createdAt': 'Created Date - Asc',
21 '-createdAt': 'Created Date - Desc',
22 'views': 'Views - Asc',
23 '-views': 'Views - Desc',
24 'likes': 'Likes - Asc',
25 '-likes': 'Likes - Desc'
29 return Object.keys(this.sortChoices);
32 getStringChoice(choiceKey: SortField) {
33 return this.sortChoices[choiceKey];
37 this.sort.emit(this.currentSort);