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'; ...@@ -3,8 +3,6 @@ import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from "@angular/forms"; import { FormsModule, ReactiveFormsModule } from "@angular/forms";
import { HttpModule } from '@angular/http'; import { HttpModule } from '@angular/http';
import { SetupModule } from './setup/setup.module';
import { WalletModule } from './wallet/wallet.module';
import { SharedModule } from './shared/shared.module'; import { SharedModule } from './shared/shared.module';
import { AppRoutingModule } from './app-routing.module'; import { AppRoutingModule } from './app-routing.module';
......
...@@ -13,7 +13,7 @@ import { RecoverComponent } from './recover/recover.component'; ...@@ -13,7 +13,7 @@ import { RecoverComponent } from './recover/recover.component';
imports: [ imports: [
CommonModule, CommonModule,
SetupRoutingModule, SetupRoutingModule,
SharedModule SharedModule.forRoot()
], ],
declarations: [ declarations: [
CreateComponent, 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 { NgModule, ModuleWithProviders } from '@angular/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { CoinNotationPipe } from './pipes/coin-notation.pipe';
import { CoinAbbreviationPipe } from './pipes/coin-abbreviation.pipe';
@NgModule({ @NgModule({
imports: [CommonModule], imports: [CommonModule],
declarations: [], declarations: [CoinNotationPipe, CoinAbbreviationPipe],
exports: [] exports: [CoinNotationPipe, CoinAbbreviationPipe]
}) })
export class SharedModule { export class SharedModule {
static forRoot(): ModuleWithProviders { static forRoot(): ModuleWithProviders {
return { return {
ngModule: SharedModule, ngModule: SharedModule,
providers: [ ] providers: []
}; };
} }
} }
<p>Balance: {{confirmedBalance}}</p> <p>Balance: {{confirmedBalance | coinNotation | coinAbbreviation}}</p>
<p>Unconfirmed: {{unconfirmedBalance}}<p> <p>Unconfirmed: {{unconfirmedBalance | coinNotation | coinAbbreviation}}<p>
\ No newline at end of file
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 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'; import { DashboardComponent } from './dashboard.component';
......
...@@ -9,12 +9,14 @@ import { SendComponent } from './send/send.component'; ...@@ -9,12 +9,14 @@ import { SendComponent } from './send/send.component';
import { ReceiveComponent } from './receive/receive.component'; import { ReceiveComponent } from './receive/receive.component';
import { HistoryComponent } from './history/history.component'; import { HistoryComponent } from './history/history.component';
import {SharedModule} from '../shared/shared.module';
import { WalletRoutingModule } from './wallet-routing.module'; import { WalletRoutingModule } from './wallet-routing.module';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, CommonModule,
FormsModule, FormsModule,
SharedModule.forRoot(),
ReactiveFormsModule, ReactiveFormsModule,
WalletRoutingModule 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