Solvedangular cli Property 'controls' does not exist on type 'AbstractControl'.
✔️Accepted Answer
Got it!
Looked at the docs - FormArray
The FormArray class contains the controls
property.
get formData() { return <FormArray>this.passwordForm.get('Data'); }
Thanks @Thisen, without you help it would've taken longer.
Other Answers:
so, my issue was solved by changing the way controls were referenced in my <md-hint>
blocks
changed to form['controls'].passwords['controls'].confirmPassword.dirty
.
can anyone expand one why this is necessary with forms? is it because of the change detection cycle? I find it quite curious that the error was only ocurring on one of my form when the pattern I was using was consistent all forms...
change:
myForm.get('some_items').controls
to:
myForm.get('some_items')['controls'];
worked for me when using --prod
Can be fixed by giving your component a get method:
get formData { return this.form.get('Data'); }
and then in your template:
<div class="form-group" *ngFor="let field of formData.controls; let i = index">
La solucion mas facil es: formGroup.controls['any']['controls'].
Bug Report or Feature Request (mark with an
x
)Versions.
@Angular/cli: 1.0.1
node: 7.5.0
os: win32 x64
Windows (10)
Repro steps.
Running the application using
ng serve
works fine.using
ng build
works fine.when using
ng build --prod --aot
orng build --prod
I get the error.It points back to this html file and the controls property??
The log given by the failure.
ERROR in ng:///C:/Angular/lanes4/src/app/containers/edit-user.component.html (34,13): Property 'controls' does exist on type 'AbstractControl'.
Desired functionality.
I would like to build it using --prod and --aot
Mention any other details that might be useful.
Happened since updating to version 4.0.0, i've just been using
ng build