moved call to explorers

This commit is contained in:
Darren Nelsen 2018-03-16 16:23:33 -04:00
parent a2ad7e4327
commit 82d5641468
4 changed files with 23 additions and 20 deletions

View File

@ -67,4 +67,4 @@
"node": ">=8"
},
"license": "MIT"
}
}

View File

@ -1,6 +1,8 @@
import { Component } from '@angular/core';
import { CurrencyProvider } from '../../providers/currency/currency';
import { ViewController } from 'ionic-angular';
import { Http } from '@angular/http';
import { ApiProvider } from '../../providers/api/api';
@Component({
selector: 'denomination',
@ -8,16 +10,28 @@ import { ViewController } from 'ionic-angular';
})
export class DenominationComponent {
public text: string;
public switcherOn: boolean;
private explorers: any = [];
public units: any = [];
constructor(
public currencyProvider: CurrencyProvider,
public viewCtrl: ViewController
public viewCtrl: ViewController,
public http: Http,
public api: ApiProvider
) {
this.text = 'Hello World';
this.switcherOn = true;
let url: string = this.api.apiPrefix + 'explorers';
this.http.get(url).subscribe(
(data) => {
this.explorers = JSON.parse(data['_body']);
this.switcherOn = true;
},
(err) => {
this.switcherOn = false;
console.error('err', err);
}
);
this.units = [
'USD',

View File

@ -11,9 +11,11 @@ import 'rxjs/add/operator/map';
@Injectable()
export class ApiProvider {
public apiPrefix: string = '/insight-api/';
public apiPrefix: string;
constructor(public http: Http) {
// TODO Make this an API call
this.apiPrefix = '/insight-api/';
}
}

View File

@ -17,23 +17,12 @@ export class CurrencyProvider {
public factor: number = 1;
private bitstamp: number;
private kraken: number;
private loading: boolean;
private explorers: any = [];
constructor(public http: Http, private api: ApiProvider) {
// TODO Make this an API call
this.defaultCurrency = 'BTC';
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 {
@ -98,11 +87,9 @@ export class CurrencyProvider {
} else if (currencyParsed.data.kraken) {
this.factor = this.kraken = currencyParsed.data.kraken;
}
this.loading = false;
},
(err) => {
console.log('err is', err);
this.loading = false;
}
);
} else if (currency === 'm' + this.defaultCurrency) {