question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FormControls updateOn property should be able to set

See original GitHub issue

πŸš€ feature request

Relevant Package

This feature request is for @angular/forms

Description

The only way to set a FormControl’s updateOn property is in the constructor. In my case I’m writing an app and a library of controls for myself and my team to use. We have a set of custom validators that all are supposed to work with updateOn: 'blur' and so in my BaseValidator (which all validators extend) I want to force updateOn: 'blur'. However, the FormControl is defined in the app that consumes the BaseValidator.

Describe the solution you’d like

const fc = new FormControl('');
fc.setUpdateMethod('blur');

Describe alternatives you’ve considered

I’ve tried to work around the issue by using setControl but to no avail.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:7
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
bene-starzengrubercommented, Jun 24, 2020

This would be very appreciated. As a workaround it is currently possible to do something like this

changeFormUpdateStrategy(formControl: FormControl, strategy: 'blur' | 'change') {
  Object.defineProperty(formControl, 'updateOn', {
    get: () => strategy,
    configurable: true
  });
}
0reactions
angular-automatic-lock-bot[bot]commented, Aug 29, 2021

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The updateOn Option in Angular Forms - InDepth.Dev
The FormControl will update itself only when the parent form is submitted. ... This is why the ability to set the updateOn property...
Read more >
Not able to set input value, when I use 'updateOn' attribute ...
updateOne will only fire when the input is blurred, that's why you'll have to do: component.input(component.
Read more >
FormControl - Angular
Tracks the value and validation status of an individual form control. ... this flag is set, the control will instead reset to the...
Read more >
Boosting Performance With The New updateOn Option in ...
Luckily, Angular version 5 provides a new option that improves performance by delaying form control updates until the blur or the submit event....
Read more >
5 tips on using Angular FormControl | by Alain Chautard
That's what the updateOn property is all about. We can delay the FormControl update process with one of these three options: blur β€”...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found