angular - Property 'xxxx' does not exist on type '{ [key: string]: AbstractControl; }' -


import { formgroup } '@angular/forms';  export class mastervendorformcontactcomponent implements oninit {   @input() formcontactgroup: formgroup; // rest of 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 in (xxx) xxx-xxxx format     </md-hint>   </md-input-container>   <!-- rest of code --> </fieldset> 

on compiling code aot 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' 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' 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' 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' not exist on type '{ [key: string]: abstractcontrol; }'. 

i tried following approach:

don’t use form.controls.controlname, use form.get(‘controlname’)

but here have formcontactgroup seems not working me.

there 2 options, can update latest typescript version. since version 2.2 allow dot notation types string index signatures.

or can change template, makes more sense because that's proper way :) documentation:

<md-input-container [dividercolor]="formcontactgroup.get('phone').valid ? 'default' : 'warn'"> 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -