Angularmaterial的datepicker与text-mask库不能很好地配合使用
创始人
2024-10-28 08:33:14
0
  1. 首先,引入text-mask库:

import createTextMaskInputElement from 'text-mask-core/src/createTextMaskInputElement'; import {Directive, ElementRef, HostListener} from '@angular/core';

@Directive({ selector: '[textMask][ngModel]' }) export class TextMaskDirective { private textMaskInputElement: any;

constructor(public elementRef: ElementRef) {}
...

}

  1. 然后,在组件中使用:

Enter a date

  1. 最后,在组件类中添加以下代码:

const rawMask = [/\d/, /\d/, '-', /\d/, /\d/, '-', /\d/, /\d/];

public dateMask = { guide: false, showMask: true, mask: rawMask };

constructor(private elementRef: ElementRef) {}

ngAfterViewInit() { setTimeout(() => { this.textMaskInputElement = createTextMaskInputElement( {inputElement: this.elementRef.nativeElement}, this.dateMask ); this.textMaskInputElement.update(this.dateValue); }, 0); // Timeout is required for avoid error: Expression has changed after it was checked }

@HostListener('input', ['$event']) onInput(event) { this.dateValue = event.target.value; }

相关内容

热门资讯

软件辅助挂!hhpoker辅助... 软件辅助挂!hhpoker辅助挂下载,德普辅助app,其实是真的有挂(果真有挂)1、很好的工具软件,...
无独有偶!newpoker怎么... 无独有偶!newpoker怎么安装脚本,德扑之星私人局辅助免费,果然是有挂(揭秘有挂)1、起透看视 ...
插件辅助挂!wepoker私人... 插件辅助挂!wepoker私人局俱乐部,德扑之星辅助工具如何打开,本来确实有挂(有挂工具)亲,关键说...
2026版方法!hhpoker... 2026版方法!hhpoker软件安装包,德扑之星私人局辅助免费,竟然是有挂(真的有挂)德扑之星私人...
更值得关注的是!aapoker... 更值得关注的是!aapoker辅助插件工具,如何下载德普之星辅助软件,切实是有挂(有挂技巧)1、用户...
值得注意的是!德普辅助软件,德... 值得注意的是!德普辅助软件,德普之星有透视辅助吗,都是真的有挂(有挂细节)1、德普之星有透视辅助吗脚...
黑科技技巧!wepoker私人... 黑科技技巧!wepoker私人局透视方法,德普辅助软件,都是存在有挂(真实有挂)1、实时德普辅助软件...
据报道!德州圈脚本,智星菠萝透... 据报道!德州圈脚本,智星菠萝透视,切实真的有挂(证实有挂)1、智星菠萝透视免费辅助多个强度级别选择2...
软件辅助挂!德普之星透视软件免... 软件辅助挂!德普之星透视软件免费入口官网,德普之星私人局辅助器,真是是真的有挂(有挂透明挂)1、完成...
随着!拱趴大菠萝挂,智星德州有... 随着!拱趴大菠萝挂,智星德州有脚本吗,一贯是有挂(有挂秘诀);1、随着!拱趴大菠萝挂,智星德州有脚本...