export class SortingType { name: string; value: string; text: string; constructor(name: string, value: string, text: string) { this.name = name; this.value = value; this.text = text; } } class SearchResultSortingController { sortings: SortingType[]; onSortingsChanged: (params: any) => void; change(sorting: SortingType) { this.update(sorting.name); this.onSortingsChanged({ sorting: sorting }); } private update(columnName: string) { this.sortings.forEach(v => { if (v.name === columnName) { switch (v.value) { case 'desc': v.value = 'asc'; break; default: v.value = 'desc'; break; } } }); } } export const SearchResultSortingComponent: angular.IComponentOptions = { controller: SearchResultSortingController, template: require('./search-result-sorting.html'), bindings: { sortings: '<', onSortingsChanged: '&' } };