import { FormGroup } from '@angular/forms';
export class MasterVendorFormContactComponent implements OnInit {
@Input() formContactGroup: FormGroup;
// rest of the code
}
<fieldset [formGroup]="formContactGroup" class="master-vendor-form-contact">
<md-input-container class="master-vendor-form-contact__phone"
[dividerColor]="formContactGroup.controls.phone?.valid ? 'default' : 'warn'">
<input mdInput placeholder="Enter phone" formControlName="phone">
<md-hint align="end"
*ngIf="!formContactGroup.controls.phone?.valid">
Vendor phone number must be in (XXX) XXX-XXXX format
</md-hint>
</md-input-container>
<!-- Rest of the code -->
</fieldset>
on compiling this code with aot it gives following error:
angular_app/src/$$_gendir/app/master-vendors/master-vendor-form-contact/master-vendor-form-contact.component.ngfactory.ts (465,73): Property 'phone' does not exist on type '{ [key: string]: AbstractControl; }'.
angular_app/src/$$_gendir/app/master-vendors/master-vendor-form-contact/master-vendor-form-contact.component.ngfactory.ts (465,143): Property 'phone' does not exist on type '{ [key: string]: AbstractControl; }'.
angular_app/src/$$_gendir/app/master-vendors/master-vendor-form-contact/master-vendor-form-contact.component.ngfactory.ts (476,77): Property 'phone' does not exist on type '{ [key: string]: AbstractControl; }'.
angular_app/src/$$_gendir/app/master-vendors/master-vendor-form-contact/master-vendor-form-contact.component.ngfactory.ts (476,147): Property 'phone' does not exist on type '{ [key: string]: AbstractControl; }'.
I tried following this approach:
Don’t use form.controls.controlName, use form.get(‘controlName’)
but here I have formContactGroup so it seems not working for me.