Initial commit
This commit is contained in:
34
src/app/components/nip/nip.component.ts
Normal file
34
src/app/components/nip/nip.component.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { AbstractControl, FormControl } from '@angular/forms';
|
||||
import { NipService } from 'src/app/service/nip.service';
|
||||
import { ClipboardService } from 'src/app/service/gui/clipboard.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-nip',
|
||||
templateUrl: './nip.component.html',
|
||||
styleUrls: ['./nip.component.scss']
|
||||
})
|
||||
export class NipComponent implements OnInit {
|
||||
public valueField: FormControl;
|
||||
|
||||
constructor(private nipService: NipService, private clipboardService: ClipboardService) {
|
||||
this.valueField = new FormControl('nip');
|
||||
this.valueField.setValidators([(control: AbstractControl) => this.nipService.validateNip(control.value)]);
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.generate();
|
||||
}
|
||||
|
||||
generate(): void {
|
||||
this.valueField.setValue(this.nipService.generateNip());
|
||||
}
|
||||
|
||||
copyToClipboard(): void {
|
||||
this.clipboardService.copyToClipboard(this.valueField.value);
|
||||
}
|
||||
|
||||
navigateToDocs(): void {
|
||||
window.open('https://pl.wikipedia.org/wiki/Numer_identyfikacji_podatkowej', "_blank");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user