-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from pegasystems/mod/tor/US-551958
updated decimal field component
- Loading branch information
Showing
3 changed files
with
42 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
packages/angular-sdk-components/src/app/_directives/thousand-seperator.directive.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
|
||
import { Directive, ElementRef, HostListener } from '@angular/core'; | ||
|
||
@Directive({ | ||
selector: '[appThousandSeparator]', | ||
standalone: true | ||
}) | ||
export class ThousandSeparatorDirective { | ||
|
||
constructor(private el: ElementRef) { } | ||
|
||
@HostListener('input', ['$event']) | ||
onInput(event) { | ||
console.log('event _onHostListenerInput', event); | ||
const input = this.el.nativeElement as HTMLInputElement; | ||
let value: any = input.value.replace(/,/g, ''); // Remove existing commas | ||
if (event?.data !== '.') { | ||
value = Number(value).toLocaleString(); // Add thousands separator | ||
input.value = value; | ||
} | ||
|
||
} | ||
} | ||
|
||
|
||
|