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; }

相关内容

热门资讯

现就发布提示!德州透视插件,德... 现就发布提示!德州透视插件,德扑之星私人局辅助免费,本来存在有挂(有挂分析)德扑之星私人局辅助免费能...
最强版We poker辅助器下... 最强版We poker辅助器下载,wpk俱乐部有没有辅助,总是是真的有挂(有挂技巧)1、这是跨平台的...
近期!wepoker能不能透视... 近期!wepoker能不能透视,德扑圈透视挂,一直真的是有挂(有挂细节)1、完成德扑圈透视挂辅助器v...
最强版hhpoker到底可以作... 最强版hhpoker到底可以作弊吗,hhpoker真的假的,原来真的是有挂(有挂解惑)1、最强版hh...
明白辅助挂!hhpoker德州... 明白辅助挂!hhpoker德州透视,德扑之星私人局辅助免费,其实确实有挂(有挂分享)1、让任何用户在...
最强版wpk控制牌是真的吗,w... 最强版wpk控制牌是真的吗,wepoker买钻石有用吗,都是真的有挂(有挂辅助)运辅助工具,进入游戏...
突发!wepoker私人局有透... 突发!wepoker私人局有透视吗,智星菠萝辅助,真是存在有挂(有挂总结)在进入智星菠萝辅助软件靠谱...
据了解!wepoker轻量版透... 据了解!wepoker轻量版透视系统,智星菠萝辅助,总是存在有挂(有挂方法)1、操作简单,无需智星菠...
推出新举措!epoker透视,... 推出新举措!epoker透视,德普辅助app,真是是真的有挂(有挂分析)在进入德普辅助app软件靠谱...
目前来看!wepoker怎么破... 目前来看!wepoker怎么破解游戏,德普之星私人局辅助免费,确实真的有挂(了解有挂)1、德普之星私...