Property 'controls' does not exist on type 'AbstractControl' Angular 4

Property 'controls' does not exist on type 'AbstractControl' Angular 4

property's or properties
property synonym
definition of property in law
what is a property in science
how to pronounce property
property for sale
los angeles luxury homes for sale
property definition math

I am trying a nested reactive form in Angular 4. It is working fine but when I try to build AOT it's throwing the error

'controls' does not exist on type 'AbstractControl'

I googled and tried few things but no luck. Could anyone tell me how to fix this issue?

<div [formGroup]="myForm">
    <div formArrayName="addresses">
        <div *ngFor="let address of myForm.get('addresses').controls; let i=index" 
                    class="panel panel-default">
            <span *ngIf="myForm.get('addresses').length > 1"
                    (click)="removeAddress(i)">Remove</span>
            <div [formGroupName]="i">
                <mat-form-field>
                    <input matInput formControlName="city" placeholder="city" value="">
                </mat-form-field>
            </div>

        </div>
    </div>
    <a (click)="addAddress()" style="cursor: default"> Add +</a>
</div>

typescript code below

constructor(private _fb: FormBuilder) {     
}

ngOnInit() {
    this.myForm = this._fb.group({
        addresses: this._fb.array([
            this.initAddress(),
        ])
    });
}
initAddress() {
    return this._fb.group({
        city: ['']
    });
}
addAddress() {
    const control = <FormArray>this.myForm.get('addresses');
    control.push(this.initAddress());
}
removeAddress(i: number) {
    const control = <FormArray>this.myForm.get('addresses');
    control.removeAt(i);
}

Based on @Günter Zöchbauer comments , first i changed

myForm.controls['addresses'] to myForm.get('addresses') in both html and typescript

and then based on @yuruzi comment

changed myForm.get('addresses').controls to myForm.get('addresses')['controls']

Its working fine now. Thanks @gunter & yuruzi

Property, synonyms: possessions, belongings, things, goods, worldly goods, effects, personal effects, stuff, chattels, movables, resources, assets, valuables, fortune, capital, riches, wealth, holdings, securities, patrimony, personalty, goods and chattels, gear, trek Search 1000's of Commercial Real Estate Listings For Lease.


You can fix it easily though. Outsource the "get the controls" logic into a method of your component code (the .ts file):

getControls() {
  return (this.recipeForm.get('controlName') as FormArray).controls;
}

In the template, you can then use:

*ngFor="let ingredientCtrl of getControls(); let i = index"

This adjustment is required due to the way TS works and Angular parses your templates (it doesn't understand TS there).

Los Angeles, CA Real Estate, "the property of heat to expand metal at uniform rates" quality, property, character, attribute mean an intelligible feature by which a thing may be identified. quality is a general term applicable to any trait or characteristic whether individual or generic.


As an update to @sunny kashyap solution, I would write it this way:

getControls() {
  return (this.recipeForm.get('controlName') as FormArray).controls;
}

Is This A Good Time To Buy An Investment Property?, Is This A Good Time To Buy An Investment Property? 2835 Potomac Ave, Los Angeles, CA 90016. ACME Real Estate. 542 Lorraine Blvd, Los Angeles, CA 90020. 9342 Van Nuys Blvd UNIT 17, Los Angeles, CA 91402. Townhouse for sale. Keller Williams Encino-Sherman Oaks. 314 S Avenue 60, Los Angeles, CA 90042. Apartment for sale. RE/MAX TOP PRODUCERS. 5813 Vanalden Ave, Tarzana, CA 91356. On market Feb 27.


to get the length of a FormArray , use simply length :

<span *ngIf="myForm.controls['addresses'].length > 1" (click)="removeAddress(i)">Remove</span>

Hope it helps

Loaded With Cash, Property Buyers Wait for Sellers to Crack, Loaded With Cash, Property Buyers Wait for Sellers to Crack 6,779 Homes For Sale in Los Angeles, CA. Browse photos, see new properties, get open house info, and research neighborhoods on Trulia.


Change myForm.get('addresses').controls to myForm.get('addresses').value will also fix the issue.

‘Investors who own Airbnb properties are looking for immediate liquidity.’ Is this a good time to buy a home?, ‘Investors who own Airbnb properties are looking for immediate liquidity.’ Is this a good time to buy a home? Property definition, that which a person owns; the possession or possessions of a particular owner: They lost all their property in the fire. See more.


Property, Property definition is - a quality or trait belonging and especially peculiar to an individual or thing. How to use property in a sentence. Synonym Discussion of  View 7749 homes for sale in Los Angeles, CA at a median listing price of $885000. Browse MLS listings in Los Angeles and take real estate virtual tours at realtor.com®.


Los Angeles, California, United States Luxury Real Estate, Property type. Any. Any; Apartments; Bed and Breakfast Homes; Condominiums; Co-op Properties; Duplex Homes; Farm and Ranch Properties; Fractional  California Property Records. Find homes for sale in California, or type an address below: We did not find listings for: Please visit our International Site for listings outside the United States


Los Angeles County property data, The first choice for your online Los Angeles County, CA real estate search. Pull out property reports, find property owners, view properties on a  Zillow has 116,678 homes for sale in California matching. View listing photos, review sales history, and use our detailed real estate filters to find the perfect place.