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

possible bug using formBuilder #32

Closed
MilesHeise opened this issue Jul 24, 2020 · 3 comments
Closed

possible bug using formBuilder #32

MilesHeise opened this issue Jul 24, 2020 · 3 comments

Comments

@MilesHeise
Copy link
Contributor

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

controls created using formBuilder do not appear to have all the features that they should

        this.formGroup = this.formBuilder.group({
            categoryKey: null,
            description: null
        });
        
        // does not work
        this.formGroup.controls.categoryKey.errors$.subscribe()

        // works
        const control = new FormControl('');
        control.errors$.subscribe(errors => {});

In this sample shown, using a directly created form control by copy pasting from the docs, the errors$ observable is present. However, trying to access the errors$ on my control created using formBuilder gives me a TS linting error saying it doesn't exist and suggesting the vanilla errors object

Expected behavior

As far as I can tell from the docs, it sounds like controls made with formBuilder should also be fully featured. I checked other items like disabled$ etc and none of them appear on the item made with formBuilder

Minimal reproduction of the problem with instructions

just create something with formBuilder and try to access items like errors$

What is the motivation / use case for changing the behavior?

To fix what appears to be broken behaviour (I apologize if I am just doing something wrong here or misinterpreting how it should work, in which case possibly a clarification added to the docs could help instead?)

Environment


Angular version: 7.2.15
TS version: 3.2.4

Browser:
- [x] Chrome (desktop) version 84
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

@tehshin
Copy link
Contributor

tehshin commented Jul 25, 2020

In the examples that are available in the readme they cast the controls to FormControl that is provided by the lib.

const address = group.getControl('name') as FormGroup<Profile['address']>;

I am not sure if it is intended like this, but it does work: https://stackblitz.com/edit/angular-ivy-tpmydz

@MilesHeise
Copy link
Contributor Author

MilesHeise commented Jul 25, 2020

interesting, I'll certainly give that a shot, thanks!

If that does work, possibly should add it to the formBuilder section of the docs. Not sure where you saw that but I went back to see if I missed it in there and it isn't covered there

@NetanelBasal
Copy link
Member

NetanelBasal commented Jul 25, 2020

Yes, this is the current behavior. See issue 23. You're welcome to add this to the form builder section.

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

3 participants