In my Formbuilder.Group method, I have included the properties as shown in the following TypeScript code:
this.form = this.fb.group({
caseNumber: ['', [Validators.required, Validators.minLength(3), Validators.maxLength(50), Validators.pattern('^[a-zA-Z0-9]*$')]],
userName: ['', [Validators.required]],
Within the Info Interface ts file, the structure is defined as follows:
export interface Information {
userName : string
caseNumber: string
}
To assign values to variables, I am using the patch value method in the following TypeScript code:
Info: Information;
this.form.patchValue({
caseNumber: this.Info.caseNumber,
userName: this.jsonArrayvalues(this.Info.userName, this.dropdownListForUserName),
Furthermore, these properties are utilized in the HTML file as demonstrated below:
<div class="form-group padding-top-bottom" [ngClass]="{'has-error': (form.get('userName').touched ||
form.get('userName').dirty) &&
!form.get('userName').valid }">
<label class="col-md-4" for="firstNameId"><span tooltip={{attributeNames.userNameTitle}} data-placement="right">Vendor Name</span></label>
<div class="col-md-7">
<ng-select [items]="userName"
multiple="true"
[addTag]="true"
bindLabel="itemName"
(change)="onItemSelect($event,'user','userName')"
formControlName="userName"
[(ngModel)]="userName">
</ng-select>
When attempting to run the command ng build --prod, an error arises:
ERROR in src\app\components\new\new.component.html(161,48): : Property 'userName' does not exist on type 'NewComponent'.
However, the same operation executes without errors when using ng build.