added call to explorers api for explorer switcher
This commit is contained in:
parent
4e9c9f5451
commit
d5b3705389
@ -4,9 +4,9 @@
|
|||||||
</ion-list-header>
|
</ion-list-header>
|
||||||
|
|
||||||
<ion-row *ngIf="switcherOn">
|
<ion-row *ngIf="switcherOn">
|
||||||
<ion-col *ngFor="let currency of currencies">
|
<ion-col *ngFor="let explorer of currencyProvider.explorers">
|
||||||
<button (click)="changeCurrency(currency)" ion-item detail-none class="text-button" text-center>
|
<button (click)="changeExplorer(explorer)" ion-item detail-none class="text-button" text-center>
|
||||||
<img src="assets/img/currency_logos/{{ currency.ticker.toLowerCase() }}.svg" class="logo"/></button>
|
<img src="assets/img/currency_logos/{{ explorer.ticker.toLowerCase() }}.svg" class="logo"/></button>
|
||||||
</ion-col>
|
</ion-col>
|
||||||
</ion-row>
|
</ion-row>
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,6 @@ export class DenominationComponent {
|
|||||||
|
|
||||||
public text: string;
|
public text: string;
|
||||||
public switcherOn: boolean;
|
public switcherOn: boolean;
|
||||||
public currencies: any = [];
|
|
||||||
public units: any = [];
|
public units: any = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ -19,18 +18,6 @@ export class DenominationComponent {
|
|||||||
) {
|
) {
|
||||||
this.text = 'Hello World';
|
this.text = 'Hello World';
|
||||||
this.switcherOn = true;
|
this.switcherOn = true;
|
||||||
this.currencies = [
|
|
||||||
{
|
|
||||||
name: 'Bitcoin',
|
|
||||||
ticker: 'BTC',
|
|
||||||
url: 'https://insight.bitpay.com'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Bitcoin Cash',
|
|
||||||
ticker: 'BCH',
|
|
||||||
url: 'https://bch-insight.bitpay.com'
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
this.units = [
|
this.units = [
|
||||||
'USD',
|
'USD',
|
||||||
@ -44,11 +31,9 @@ export class DenominationComponent {
|
|||||||
this.viewCtrl.dismiss();
|
this.viewCtrl.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
public changeCurrency(currency: any): void {
|
public changeExplorer(explorer: any): void {
|
||||||
console.log('selected currency is', currency.name, currency.ticker);
|
|
||||||
this.close();
|
this.close();
|
||||||
let theUrl: string = currency.url;
|
let theUrl: string = explorer.url;
|
||||||
console.log('theUrl is', theUrl);
|
|
||||||
window.location.href = theUrl;
|
window.location.href = theUrl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,10 +18,22 @@ export class CurrencyProvider {
|
|||||||
private bitstamp: number;
|
private bitstamp: number;
|
||||||
private kraken: number;
|
private kraken: number;
|
||||||
private loading: boolean;
|
private loading: boolean;
|
||||||
|
private explorers: any = [];
|
||||||
|
|
||||||
constructor(public http: Http, private api: ApiProvider) {
|
constructor(public http: Http, private api: ApiProvider) {
|
||||||
this.defaultCurrency = 'BCH';
|
this.defaultCurrency = 'BCH';
|
||||||
this.currencySymbol = this.defaultCurrency;
|
this.currencySymbol = this.defaultCurrency;
|
||||||
|
|
||||||
|
this.http.get(this.api.apiPrefix + 'explorers').subscribe(
|
||||||
|
(data) => {
|
||||||
|
this.explorers = JSON.parse(data['_body']);
|
||||||
|
this.loading = false;
|
||||||
|
},
|
||||||
|
(err) => {
|
||||||
|
console.log('err is', err);
|
||||||
|
this.loading = false;
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public roundFloat(aFloat: number, decimalPlaces: number): number {
|
public roundFloat(aFloat: number, decimalPlaces: number): number {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user