Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Directive({
- selector: '[numericControl]'
- })
- export class NumericControlDirective {
- contructor(
- private el: ElementRef,
- ) {}
- @HostListener('input', ['$event'])
- onInput(e: any) {
- if (e.which < 48 || e.which > 57) {
- e.preventDefault();
- }
- }
- }
- <input type="text" placeholder="Volume" numericControl />
Add Comment
Please, Sign In to add comment