i am bigginer in angular,my form in html is :
<mat-card style="padding:20px;margin:30px;text-align: right;">
<mat-card-header>
<mat-card-title>title</mat-card-title>
</mat-card-header>
<mat-card-content style="width: 150px; display: contents;" [formGroup]="formGroupContent">
<div>
<mat-form-field class = "tp-full-width" style="padding-left: 20px;">
<input #amvalcode formControlName="equiid" matInput placeholder = "code" value = "">
</mat-form-field>
</mat-card-content>
<mat-card-actions >
<button mat-raised-button color="accent" type="button" style="width:200px;"
(click)="add_equi(captioncode.selected.value.id)">add</button>
</mat-card-actions>
and in type script :
add_equi(CaptionCode){
if (this.formGroupContent.controls['equiid']?.value === undefined){
console.log("undefined value");
}else{
console.log("has value");
}
}
equiid is formControlName ,but when in equiid is null i recive
Cannot read property 'value' of undefined