Commit e6bcd1ba authored by dev0tion's avatar dev0tion

Add notation and abbreviation pipes

parent e75c606e
......@@ -3,8 +3,6 @@ import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
import { HttpModule } from '@angular/http';
import { SetupModule } from './setup/setup.module';
import { WalletModule } from './wallet/wallet.module';
import { SharedModule } from './shared/shared.module';
import { AppRoutingModule } from './app-routing.module';
......
......@@ -13,7 +13,7 @@ import { RecoverComponent } from './recover/recover.component';
imports: [
CommonModule,
SetupRoutingModule,
SharedModule
SharedModule.forRoot()
],
declarations: [
CreateComponent,
......
import { CoinAbbreviationPipe } from './coin-abbreviation.pipe';
describe('CoinAbbreviationPipe', () => {
it('create an instance', () => {
const pipe = new CoinAbbreviationPipe();
expect(pipe).toBeTruthy();
});
});
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'coinAbbreviation'
})
export class CoinAbbreviationPipe implements PipeTransform {
transform(value: any): any {
if (!value) return value;
let abbreviationAdded = value + " BTC"
return abbreviationAdded;
}
}
import { CoinNotationPipe } from './coin-notation.pipe';
describe('CoinNotationPipe', () => {
it('create an instance', () => {
const pipe = new CoinNotationPipe();
expect(pipe).toBeTruthy();
});
});
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'coinNotation'
})
export class CoinNotationPipe implements PipeTransform {
transform(value: any): any {
if (!value) return value;
let coinNotation = Number(value).toFixed(8);
return coinNotation;
}
}
import { NgModule, ModuleWithProviders } from '@angular/core';
import { CommonModule } from '@angular/common';
import { CoinNotationPipe } from './pipes/coin-notation.pipe';
import { CoinAbbreviationPipe } from './pipes/coin-abbreviation.pipe';
@NgModule({
imports: [CommonModule],
declarations: [],
exports: []
declarations: [CoinNotationPipe, CoinAbbreviationPipe],
exports: [CoinNotationPipe, CoinAbbreviationPipe]
})
export class SharedModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: SharedModule,
providers: [ ]
providers: []
};
}
}
<p>Balance: {{confirmedBalance}}</p>
<p>Unconfirmed: {{unconfirmedBalance}}<p>
\ No newline at end of file
<p>Balance: {{confirmedBalance | coinNotation | coinAbbreviation}}</p>
<p>Unconfirmed: {{unconfirmedBalance | coinNotation | coinAbbreviation}}<p>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CoinNotationPipe } from '../../shared/pipes/coin-notation.pipe';
import { CoinAbbreviationPipe } from '../../shared/pipes/coin-abbreviation.pipe';
import { DashboardComponent } from './dashboard.component';
......
......@@ -9,12 +9,14 @@ import { SendComponent } from './send/send.component';
import { ReceiveComponent } from './receive/receive.component';
import { HistoryComponent } from './history/history.component';
import {SharedModule} from '../shared/shared.module';
import { WalletRoutingModule } from './wallet-routing.module';
@NgModule({
imports: [
CommonModule,
FormsModule,
SharedModule.forRoot(),
ReactiveFormsModule,
WalletRoutingModule
],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment