Advertisement
Buffet_Time

ignore this meme

Aug 7th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. import { Component } from '@angular/core';
  2. import { CoinMarketCapService } from '../services/coin-market-cap.service';
  3.  
  4. @Component({
  5. selector: 'app-root',
  6. templateUrl: './app.component.html',
  7. styleUrls: ['./app.component.css']
  8. })
  9. export class AppComponent
  10. {
  11. currenciesJson: object;
  12. selectedCurrency: object;
  13. currencyId: any;
  14. displayInfo: boolean = false;
  15. finishedLoading: boolean = false;
  16.  
  17. constructor(private CoinMarketCapService: CoinMarketCapService) {}
  18.  
  19. ngOnInit()
  20. {
  21. this.CoinMarketCapService.getCurrencies(15)
  22. .then(res => {
  23. this.currenciesJson = res,
  24. this.finishedLoading = true;
  25. });
  26. }
  27.  
  28. selectCurrency(currencyId: number)
  29. {
  30. console.log(currencyId);
  31. this.CoinMarketCapService.getCurrency(currencyId)
  32. .then( res => {
  33. this.currencyId = currencyId,
  34. this.selectedCurrency = res,
  35. console.log(res);
  36. })
  37. .then( res =>
  38. this.showInfo(true)
  39. )
  40. }
  41.  
  42. showInfo ( showInfo: boolean )
  43. {
  44. this.displayInfo = showInfo;
  45. }
  46. }
  47.  
  48.  
  49.  
  50. <div [class.app-dark-theme]="true">
  51. <mat-sidenav-container fullscreen class="sidenav-container">
  52. <mat-toolbar class="toolbar">
  53. Coin Market Cap 3rd party api app
  54. </mat-toolbar>
  55.  
  56. <mat-card>
  57. <mat-card-header>
  58. <mat-card-title>CryptoCurrency Market Overview</mat-card-title>
  59. <mat-card-subtitle>Top 15 current currencies.</mat-card-subtitle>
  60. </mat-card-header>
  61.  
  62. <mat-card-content class="currency-listings">
  63. <div *ngIf="finishedLoading">
  64. <mat-grid-list cols="1" rowHeight="40px">
  65. <mat-grid-tile *ngFor="let currency of currenciesJson.data | keyvalue; let i = index" (click)="selectCurrency(currency.value.id)">
  66. {{i + 1}} - {{currency.value.name}}
  67. </mat-grid-tile>
  68. </mat-grid-list>
  69. </div>
  70. </mat-card-content>
  71. </mat-card>
  72.  
  73. <mat-card *ngIf="displayInfo">
  74. {{selectedCurrency.data[0].name}}
  75. </mat-card>
  76. </mat-sidenav-container>
  77. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement