-
Notifications
You must be signed in to change notification settings - Fork 25.6k
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
Getting Error: Cannot find control '0' when implementing FormArray as shown in Google doc guide #9251
Comments
@qdouble you have to match the
Since you're using the index as the name of the control, the controls key should be numbers. I would say it's more something missing in the doc than a bug, although I may be wrong. cc @kara |
@ericmartinezr that doesn't appear to work either. I see they've labeled it, so I suppose it is indeed a bug. |
The planned updates to forms are still very much in progress, so a few things in the proposal doc aren't implemented yet and are slated for the next release (namely, formArrayName and form level updateValue). I've updated the original proposal doc to clarify these are still to come. I'll keep this issue open so it's easier to track its completion. Sorry for the confusion! |
Is it possible to make FormArray fallback to its controls[0] for controls[1] when controls[1] is missing? I am building a Angular 2 Form generator. It generates proper FormGroup, FormArray, FormControl but I am stucked as when generating form according to object schema I don't know how many objects contained inside FormArray. Generated Form equivalent: this.form = new FormGroup({
myArr: new FormArray([
new FormControl('')
])
}) When I set value -> I understand the reason why, but it can be fixed if Angular 2 Form can fall back to myArr.controls[0] for all sibilings Form. Thanks |
Maybe this will help you as an idea
|
I was ecountering same issue. This way it helped me.
<form [formGroup]="invoiceForm">
<div formArrayName="patterns">
<div *ngFor="let pattern of invoiceForm.controls.patterns.controls ; let i = index">
<br>
<h6>Pattern {{i+1}}</h6>
<button type="submit" class='"btn btn-warning pull-right" (click)="deletePatterns(i)"> Remove</button>
<div>
<label>Value</label>
<input formControlName="{{i}}" placeholder="Text" class="form-control">
</div>
</div>
</div>
</form>
|
Hi Guys, I am also facing the same issue. When I click on add hotspot it is throwing an error "No value accessor for 'hotspots -> 0'" Please help me |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Current behavior
When implementing FormArray as shown in guide: https://docs.google.com/document/u/1/d/1RIezQqE4aEhBRmArIAS1mRIZtWFf6JxN_7B4meyWK0Y/pub
I get an error >browser_adapter.js:77 Error: Cannot find control '0'
You can see the issue here: https://plnkr.co/edit/ir19tuktTqcfGeG8pu2G?p=preview
The text was updated successfully, but these errors were encountered: