moved call to explorers
This commit is contained in:
parent
a2ad7e4327
commit
82d5641468
@ -1,6 +1,8 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { CurrencyProvider } from '../../providers/currency/currency';
|
import { CurrencyProvider } from '../../providers/currency/currency';
|
||||||
import { ViewController } from 'ionic-angular';
|
import { ViewController } from 'ionic-angular';
|
||||||
|
import { Http } from '@angular/http';
|
||||||
|
import { ApiProvider } from '../../providers/api/api';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'denomination',
|
selector: 'denomination',
|
||||||
@ -8,16 +10,28 @@ import { ViewController } from 'ionic-angular';
|
|||||||
})
|
})
|
||||||
export class DenominationComponent {
|
export class DenominationComponent {
|
||||||
|
|
||||||
public text: string;
|
|
||||||
public switcherOn: boolean;
|
public switcherOn: boolean;
|
||||||
|
private explorers: any = [];
|
||||||
public units: any = [];
|
public units: any = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public currencyProvider: CurrencyProvider,
|
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 = [
|
this.units = [
|
||||||
'USD',
|
'USD',
|
||||||
|
|||||||
@ -11,9 +11,11 @@ import 'rxjs/add/operator/map';
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class ApiProvider {
|
export class ApiProvider {
|
||||||
|
|
||||||
public apiPrefix: string = '/insight-api/';
|
public apiPrefix: string;
|
||||||
|
|
||||||
constructor(public http: Http) {
|
constructor(public http: Http) {
|
||||||
|
// TODO Make this an API call
|
||||||
|
this.apiPrefix = '/insight-api/';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,23 +17,12 @@ export class CurrencyProvider {
|
|||||||
public factor: number = 1;
|
public factor: number = 1;
|
||||||
private bitstamp: number;
|
private bitstamp: number;
|
||||||
private kraken: number;
|
private kraken: number;
|
||||||
private loading: boolean;
|
|
||||||
private explorers: any = [];
|
|
||||||
|
|
||||||
constructor(public http: Http, private api: ApiProvider) {
|
constructor(public http: Http, private api: ApiProvider) {
|
||||||
|
// TODO Make this an API call
|
||||||
this.defaultCurrency = 'BTC';
|
this.defaultCurrency = 'BTC';
|
||||||
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 {
|
||||||
@ -98,11 +87,9 @@ export class CurrencyProvider {
|
|||||||
} else if (currencyParsed.data.kraken) {
|
} else if (currencyParsed.data.kraken) {
|
||||||
this.factor = this.kraken = currencyParsed.data.kraken;
|
this.factor = this.kraken = currencyParsed.data.kraken;
|
||||||
}
|
}
|
||||||
this.loading = false;
|
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
console.log('err is', err);
|
console.log('err is', err);
|
||||||
this.loading = false;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else if (currency === 'm' + this.defaultCurrency) {
|
} else if (currency === 'm' + this.defaultCurrency) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user