import {Component, Input, Output, EventEmitter} from '@angular/core'; import {Observable} from 'rxjs/Observable'; import {Router, ActivatedRoute} from '@angular/router'; import {RouterHelper} from '../../utils/routerHelper.class'; @Component({ selector: 'search-sorting', template: ` Sort by: ` }) export class SearchSortingComponent { /*@Input() searchUtils; @Input() baseUrl; @Input() parameterNames:string[]; @Input() parameterValues:string[]; */ @Input() sortBy: string=""; @Output() sortByChange = new EventEmitter(); //public routerHelper:RouterHelper = new RouterHelper(); constructor (/*private route: ActivatedRoute, private _router: Router*/) {} ngOnInit() {} /*navigateSort(sortBy: string) { this.searchUtils.page = 1; console.info("sortBy="+sortBy); if(sortBy) { this._router.navigate([this.baseUrl], { queryParams: this.routerHelper.createQueryParamsSortBy(this.parameterNames, this.parameterValues, 'sortBy', sortBy)}); } else { let index: number = this.parameterNames.findIndex(function(element) { return element == "sortBy"; }); console.info("index of sortby: "+index); if(index >= 0) { this.parameterNames.splice(index, 1); this.parameterValues.splice(index, 1); } this._router.navigate([this.baseUrl], { queryParams: this.routerHelper.createQueryParams(this.parameterNames, this.parameterValues)}); } }*/ sortByChanged() { this.sortByChange.emit({ value: this.sortBy }); } }