Skip to content

Infragistics Community Forum / Web / Ignite UI for Angular / Is a dynamic Input Mask achievable?

Is a dynamic Input Mask achievable?

New Discussion
Jacky Nguyen
Jacky Nguyen asked on Nov 21, 2019 1:41 AM

Hi there

I’ve been trying to make a sort of dynamic input mask that changes based on user input.

Expected:

1. If the first keydown is a word, it should render Canada Postal Code mask.

2. If it is a number, renders USA Postal Code mask.

Actual:

The input doesn’t get updated with the new mask.

I also prepared a StackBlitz for this: https://stackblitz.com/edit/angular-9sr8ok?file=src/app/mask-sample-5/mask-sample-5.component.html

Sign In to post a reply

Replies

  • 0
    N. Ishibashi
    N. Ishibashi answered on Nov 19, 2019 7:34 AM

    Hello Jacky Nguyen,

    Thank you for making a post to our forum and sharing the reproducible sample.

    This is just a short notice that we received your inquiry and that we are under investigation about your issue. If we have an update, I'll let you know. So could you wait for a while?

    Thank you in advance.

    • 0
      Jacky Nguyen
      Jacky Nguyen answered on Nov 19, 2019 9:22 AM

      Thanks, let me know if you need more information on this case.

      • 0
        N. Ishibashi
        N. Ishibashi answered on Nov 20, 2019 4:27 AM

        Hello Jacky Nguyen,

        Thank you for sharing the sample. We investigated it and it turns out that it won't work because Angular does not make deep checks for @Input values. It means that Angular only compares primitives by value and coumpound types by reference. Therefore, changing the value of the currentMask does not trigger change detection because its reference is still the same.

        Here are a modified sample: https://stackblitz.com/edit/angular-9sr8ok-nwcyer

        I hope this will help.

      • 0
        Jacky Nguyen
        Jacky Nguyen answered on Nov 20, 2019 4:44 AM

        Hi there,

        Thank you for your response.

        The modified sample is not correct for my use case, plus I deep clone `currentMask` at the following line:

                this.currentMask = JSON.parse(JSON.stringify(newMask)); // Angular should do a deep check.

        By my investigation, I think the igxMask can't be updated after the parent component ViewInit, you can see it quite clearly in your modified sample, try clicking `Change mask` and focus on the input, the mask is still the same mask as before.

      • 0
        N. Ishibashi
        N. Ishibashi answered on Nov 21, 2019 1:41 AM

        Hello Jacky Nguyen,

        Thank you for pointing out. I just saw that the placeholder was changed and wrongly considered that it worked as well as for the mask. Sorry for that.

        Receiving the indication, we made more investigation and it has turned out that we don't support changing mask pattern after it is initialized.

        Sorry to bother you, but could you submit a bug or a feature request to our GitHub site https://github.com/IgniteUI/igniteui-angular/issues if this feature is very important for you? Submitting your idea will allow you to communicate directly with our product management team and track the progress of your idea at any time.

        Thank you in advance to making a submit.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Jacky Nguyen
Favorites
0
Replies
5
Created On
Nov 21, 2019
Last Post
6 years, 3 months ago

Suggested Discussions

Created by

Created on

Nov 21, 2019 1:41 AM

Last activity on

Feb 23, 2026 6:10 AM