angular/projects/researchdatabox/dashboard/src/app/sort/sort.component.ts
selector | sort |
styleUrls | ./sort.component.scss |
templateUrl | ./sort.component.html |
Methods |
Inputs |
Outputs |
secondarySort | |
Type : string
|
|
Default value : ''
|
|
sort | |
Type : string
|
|
Default value : ''
|
|
step | |
Type : string
|
|
Default value : ''
|
|
title | |
Type : string
|
|
Default value : ''
|
|
variable | |
Type : string
|
|
Default value : ''
|
|
sortChanged | |
Type : EventEmitter
|
|
sortClicked |
sortClicked()
|
Returns :
boolean
|
import { Component, Input, Output, EventEmitter } from '@angular/core';
@Component({
selector: 'sort',
templateUrl: './sort.component.html',
styleUrls: ['./sort.component.scss']
})
export class SortComponent {
@Input() sort: string = '';
@Input() title: string = '';
@Input() step: string = '';
@Input() variable: string = '';
@Input() secondarySort: string = '';
@Output() sortChanged = new EventEmitter();
sortClicked() {
if (this.sort != null) {
if (this.sort == "asc") {
this.sort = "desc";
} else {
this.sort = "asc";
}
} else {
this.sort = "asc";
}
this.sortChanged.emit({title:this.title, variable:this.variable, sort:this.sort, step:this.step, secondarySort:this.secondarySort});
return false;
}
}
<a href="#" role="button" [attr.aria-sort]="sort === 'asc'? 'ascending' : sort === 'desc' ? 'descending' : null" (click)="sortClicked()">{{title}} <i *ngIf="sort == 'asc'"class="fa fa-sort-asc"></i><i *ngIf="sort == 'desc'"class="fa fa-sort-desc"></i></a>
./sort.component.scss