Giter VIP home page Giter VIP logo

Comments (3)

maequise avatar maequise commented on May 29, 2024 1

Hi @Dejavu333 ,

I don't understand the motivations of the following points, maybe could explain it a little more :

1.Formcontrol should know whether it is focused, submitted.

The focused property can easily find a utility, but for the submit, what use cases have you in mind (for the FormControl particulary, as for the FormGroup it can find a useful usage) ?
Anyway the [formGroup] directive has an property that track the submit status :

<form [formGroup]="form" (ngSubmit)="submit()" #formDir=ngForm>
    <input type="text" formControlName="test" />
    <button type="submit">submit</button>
  </form>
  <span>{{formDir.submitted}}</span>

What have you in mind for the focus event ?

2.We should be able to add multiple updateOn values not just one.

Does it make any sense to have a stream for the focus event anymore ? What are you planning to listen for the focus event ? I think that the events streamed for the update should be bounded to avoid any overload during the listening of events.

The third point makes sense.

from angular.

Dejavu333 avatar Dejavu333 commented on May 29, 2024 1

1 and 2 kinda goes hand in hand.
Currently, FormControl validations are tightly coupled and can only be triggered by a single event, which limits flexibility. For instance, you might want to trigger different validators for FormGroup and FormControl, but the current setup doesn’t allow for this differentiation, since the updateValueAndValidity function triggers valueChanges in the parent FormGroup, which in turn activates its validators. This becomes an issue when you want your controls' validators to be triggered by different events - for example, one on ‘blur’ and ‘hover’ (this is where multiple values would come into play), another on ‘change’, and the FormGroup validators on ‘submit’ and ‘submit’ only.

It would be beneficial to decouple these elements to allow for more granular control over when and how validations are triggered.

from angular.

Dejavu333 avatar Dejavu333 commented on May 29, 2024

I've started to implement a new approach, where you can instantiate a formControl like this:
image

Cleaner and can achieve the desired behaviour I stated above.

from angular.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.