-2

I am new to angular and i am struggling a bit with typeError

Cannot read property 'attributeSourceSystem' of undefined

Html Content

<p-dropdown class="p-primeNg" placeholder="Source" [options]="lookupDataSourceNgDropdown" [(ngModel)]="selectedAttributeObj.attributeSourceSystem"
                                (ngModelChange)="selectAttributeSourceSystem(selectedAttributeObj); checkFilter('ROW');" optionLabel="templateName"
                                [filter]="true"></p-dropdown>

anyone know how to resolve ?

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
Harsha Mullangi
  • 474
  • 1
  • 6
  • 27

1 Answers1

0

If you want to solve, you have to avoid to use the two way binding, use just [ngModel] and the 'elvis' operator ? on this selectedAttributeObj?.attributeSourceSystem

<p-dropdown class="p-primeNg" placeholder="Source" [options]="lookupDataSourceNgDropdown" [ngModel]="selectedAttributeObj?.attributeSourceSystem"
                                (ngModelChange)="selectAttributeSourceSystem(selectedAttributeObj); checkFilter('ROW');" optionLabel="templateName"
                                [filter]="true"></p-dropdown>

You should have a look here: https://angular.io/guide/template-syntax#ngmodel-two-way-binding

Frank Pentangeli
  • 336
  • 2
  • 6
  • 20