Ngx-mask: Interferes with Disabled Attribute

Created on 6 Mar 2018  路  4Comments  路  Source: JsDaddy/ngx-mask

I'm trying to use a mask with an _input_ that has the _disabled_ attribute that can be toggled off and on:

template:

<input id="phone" name="phone" mask="000-000-0000" [(ngModel)]="phoneNumber" [disabled]="isDisabled" />
<button type="button" (click)="toggleDisabled()">Toggle</button>

component:

export class MaskComponent {
    phoneNumber: string = '1231231234';
    isDisabled: boolean = false;

    toggleDisabled() {
        this.isDisabled = this.isDisabled ? false : true;
    }
}

The disabled toggle works correctly until I add the _mask_ directive. When I do, it disables the _input_ and seems to ignore the _disabled_ attribute.

bug help wanted

Most helpful comment

The last version worked perfect for me.
Thank you!

All 4 comments

I encountered the same problem. What I noticed is that the disable/re-enable behavior works correctly if I do not bind to a form control (e.g. do not have [(ngModel)]="phoneNumber" ). When I do have a form control, as soon as I pass [disabled]="true" in, the input remains disabled from then on, even if I set [disabled]="false".

The problem also happened to me.

Work around the problem by creating two inputs.

@natan88 @kcoram @cabbott65 Please try last version and give feedback

The last version worked perfect for me.
Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

prosto-artem picture prosto-artem  路  4Comments

daliri72 picture daliri72  路  4Comments

ghost picture ghost  路  3Comments

sbeka picture sbeka  路  3Comments

salazarr-js picture salazarr-js  路  3Comments