As per Angular documentation, there is no orderBy pipe available to sort. As per the documentation I have to implement the sort in the component by myself. As I am very new to Angular, I am unsure, how to go about it. Can somebody please help out? I am looking for the actual code, which will do the trick.
I want to sort issuer dropdown in an ascending order. ts file is as follows
import { Component, OnInit } from '@angular/core';
import { IssuerDropdownService } from './service/issuer-dropdown.service';
import { DisputeDataSessionService } from 'src/app/service/dispute.session.service'
@Component({
selector: 'app-issuer-dropdown',
templateUrl: './issuer-dropdown.component.html',
styleUrls: ['./issuer-dropdown.component.scss']
})
export class IssuerDropdownComponent implements OnInit {
constructor(public issuerService: IssuerDropdownService, public session: DisputeDataSessionService) { }
issuerList: any = [];
ngOnInit(): void {
this.issuerService.getIssuerList().subscribe(res => {
this.issuerList=res.data;
})
}
selectIssuer(issuer) {
this.issuerService.issuer = issuer.issuerName;
this.session.setSubscriberId(issuer.subscriberId);
this.session.setCountryCode(issuer.issuerCountryCode);
}
}
<mat-form-field appearance="outline" >
<mat-label translate>Issuer</mat-label>
<mat-select placeholder="Choose an Issuer" [(ngModel)]="this.issuerService.issuer" class="issuerSelectPanel">
<mat-option (click)="selectIssuer(issuer)" *ngFor="let issuer of issuerList" [value]="issuer.issuerName" >{{ issuer.issuerName }}</mat-option>
</mat-select>
</mat-form-field>