Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toggle lazy:true/false on focus/blur using Angular plugin #380

Closed
shateeshb opened this issue Jul 7, 2020 · 3 comments
Closed

toggle lazy:true/false on focus/blur using Angular plugin #380

shateeshb opened this issue Jul 7, 2020 · 3 comments

Comments

@shateeshb
Copy link

hi all, is there a way to toggle the lazy option for the mask on focus/blur using the angular plugin?

this is how I am currently using imask. I am a newbie to angular and am not sure how when blur and focus methods are called, but it this is not updating the lazy option the way I'd expect:

// template
<input 
  [imask]="imaskOptions"
  [unmask]="false"
  (blur)="onBlur($event)"
  (focus)="onFocus($event)"
  (accept)="onAccept($event)"
  (complete)="onComplete($event)"
/>

// class 
imaskOptions = {
  mask: "00/00/0000", 
  lazy: this.isLazy, 
}

isLazy = false

onBlur() {
  this.isLazy = true
}

onFocus() {
  this.isLazy = false
}

is there a recommendation to achieve something like this?

@danielreiser
Copy link

danielreiser commented Jul 8, 2020

You can get hold of the imask instance via the directive and then use the mask.updateOptions({}) method.

@ViewChild('imask', { read: IMaskDirective }) imask: IMaskDirective<MaskedPattern>;

public onBlur(): void {
  this.imask.updateOptions({...});
}

@shateeshb
Copy link
Author

thanks!

@dstj
Copy link

dstj commented Jun 24, 2021

Isn't there a maskRef missing in there? The correct syntax seems to be (w/ v6.0.7):

this.imask.maskRef.updateOptions({...});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants