import { Directive , ElementRef , HostListener } from '@angular/core' ; import { NgControl } from '@angular/forms' ; import { Address } from '@signumjs/core' ; @ Directive ( { selector : '[pasteableAddress]' , } ) export class PasteableAddressDirective { constructor ( private el , private control ) { } @ HostListener ( 'paste' , [ '$event' ] ) onEvent ( $event ) { $event . preventDefault ( ) ; const data = $event . clipboardData . getData ( 'text' ) ; try { const address = Address . fromReedSolomonAddress ( data ) ; this . control . control . setValue ( address . getReedSolomonAddress ( false ) ) ; } catch ( e ) { } } }