如何在angular 6中手动添加或删除输入掩码?
我使用ngx掩码,无法从指令中动态删除或添加它。如何在angular 6中手动添加或删除输入掩码?,angular,angularjs-directive,Angular,Angularjs Directive,我使用ngx掩码,无法从指令中动态删除或添加它。 当我使用事件发射器并重新绑定值时,它不会发生任何变化。尝试以下方法: HTML: <input matInput [mask]="myMask" [(ngModel)]="dateModel"> <button type="button" (click)="removeMask()">RemoveMask</button> <button type="button" (click)="addMask(
当我使用事件发射器并重新绑定值时,它不会发生任何变化。尝试以下方法: HTML:
<input matInput [mask]="myMask" [(ngModel)]="dateModel">
<button type="button" (click)="removeMask()">RemoveMask</button>
<button type="button" (click)="addMask()">AddMask</button>
export class AppComponent {
myMask = '(0000)';
tempData: null;
public dateModel;
removeMask() {
this.myMask = null;
this.tempData = this.dateModel;
this.dateModel = null
}
addMask() {
this.dateModel = this.tempData;
this.myMask = '(0000)'
}
}