File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change 11export class Patron {
22 id : Number
33 fullName : string
4- amount : Number
4+ amount : number
55 email : boolean
66 active : boolean
77}
Original file line number Diff line number Diff line change 11import { Component , OnInit } from '@angular/core' ;
22import { PatronList } from "../model/patron.list" ;
33import { PatronService } from "../service/patron.service" ;
4- import { Router } from "@angular/router" ;
54
65@Component ( {
76 selector : 'app-patrons-list' ,
@@ -12,14 +11,21 @@ export class PatronsListComponent implements OnInit {
1211
1312 patronList : PatronList ;
1413
15- constructor ( private patronService : PatronService , private router : Router ) { }
14+ constructor ( private patronService : PatronService ) { }
1615
1716 ngOnInit ( ) {
1817 this . patronService . getPatronList ( ) . subscribe ( data => {
1918 this . patronList = data ;
19+ this . sortPatronsByAmount ( ) ;
2020 } ) ;
2121 }
2222
23+ sortPatronsByAmount ( ) : void {
24+ this . patronList . patrons . sort ( function ( a , b ) {
25+ return b . amount - a . amount
26+ } )
27+ }
28+
2329 transformPrice ( val : number ) : number {
2430 return val / 100 ;
2531 }
You can’t perform that action at this time.
0 commit comments