Added form validation to broadcast transaction
This commit is contained in:
parent
130b7a7022
commit
615ffc59db
@ -8,18 +8,24 @@
|
|||||||
</ion-header>
|
</ion-header>
|
||||||
|
|
||||||
<ion-content padding>
|
<ion-content padding>
|
||||||
<ion-list>
|
<form [formGroup]="txForm">
|
||||||
<ion-item>
|
<ion-list>
|
||||||
<p>This form can be used to broadcast a raw transaction in hex format over the Bitcoin network.</p>
|
<ion-item>
|
||||||
</ion-item>
|
<p>This form can be used to broadcast a raw transaction in hex format over the Bitcoin network.</p>
|
||||||
|
</ion-item>
|
||||||
|
|
||||||
<ion-item>
|
<ion-item>
|
||||||
<ion-label floating>Raw transaction data</ion-label>
|
<ion-label floating>Raw transaction data</ion-label>
|
||||||
<ion-input type="text"></ion-input>
|
<ion-input type="text" [(ngModel)]="transaction" formControlName="rawData"></ion-input>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
|
|
||||||
<ion-item>
|
<ion-item *ngIf="!txForm.controls.rawData.valid">
|
||||||
<button ion-button outline>Send transaction</button>
|
<p>Raw transaction data must be a valid hexadecimal string.</p>
|
||||||
</ion-item>
|
</ion-item>
|
||||||
</ion-list>
|
|
||||||
|
<ion-item>
|
||||||
|
<button ion-button outline (click)="send()" [disabled]="!txForm.touched || !txForm.valid">Send transaction</button>
|
||||||
|
</ion-item>
|
||||||
|
</ion-list>
|
||||||
|
</form>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { NavController } from 'ionic-angular';
|
import { NavController } from 'ionic-angular';
|
||||||
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: './broadcastTxPage.html'
|
templateUrl: './broadcastTxPage.html'
|
||||||
@ -9,9 +10,22 @@ export class BroadcastTxPage {
|
|||||||
|
|
||||||
public title: string;
|
public title: string;
|
||||||
private nav: NavController;
|
private nav: NavController;
|
||||||
|
public transaction: string;
|
||||||
|
public txForm: FormGroup;
|
||||||
|
|
||||||
constructor(nav: NavController) {
|
constructor(nav: NavController, public formBuilder: FormBuilder) {
|
||||||
this.nav = nav;
|
this.nav = nav;
|
||||||
this.title = 'Broadcast Transaction';
|
this.title = 'Broadcast Transaction';
|
||||||
|
this.txForm = formBuilder.group({
|
||||||
|
rawData: ['', Validators.pattern(/^[0-9A-Fa-f]+$/)]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
send() {
|
||||||
|
let postData = {
|
||||||
|
rawtx: this.transaction
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log('the postData is', postData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user