Skip to content

use FormControlDirective for not standalone FormControls #13978

@advgal

Description

@advgal

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[X] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior
If you want to bind reactive forms to dom element you have to use FormControlName.

Expected behavior
I want to be able to bind form controls of a FormGroup to a dom element by using the FormControl directive. The api reference says:
"Syncs a standalone FormControl instance to a form control element."
I want to use it not only on standalone FormControls

Minimal reproduction of the problem with instructions
that's the code I want to write

<!--outer component-->
<ul [formArrayName]="array">
  <li *ngFor="let control of form.get(key).controls">

    <app-text [control]="control"></app-text>

  </li>
</ul>
<app-text [control]="form.get(key2)"></app-text>

<!--text-box component-->
<input [formControl]="control" type="text">

What is the motivation / use case for changing the behavior?
I want to pass the FormControl to a component and the component does not need to know the FormGroup or FormArray the FormControl is a child of.

Please tell us about your environment:

  • Angular version: 2.1.X
  • Browser: [all ]
  • Language: [all]

  • Node (for AoT issues): node --version =

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions