Vikram R Vikram R - 3 years ago 162
Javascript Question

differ supporting object '[object Object]' of type

I am getting

ERROR Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.


ts file:

this.list = data.json();
console.log("=====>"+JSON.stringify(this.list));


list data:

=====>{"CorpBusiness":[{"cpbusid":437,"cpbuscpcdid":18315,"cpbuscpliid":1,"cpbus_cin_no":null,"cpbus_industry":1001,"cpbus_score":0,"cpbus_loantaken":1,"cpbus_delayed":36,"cpbus_exdraws":42,"cpbus_trans":45,"cpbus_prop_ownship":0,"cpbus_createdby":null,"cpbus_createdon":null,"cpbus_updatedby":null,"cpbus_updatedon":null,"cpbus_auth_creditchk":"u","cpbus_prop_type":0,"cpbus_market_val":0,"cpbus_loan_on_prop":0,"cpbus_payment_hist":33}],"CorpFinancial":[{"cpfinid":973,"cpfincpdtid":18315,"cpfinliid":1,"cpfin_yr":"2","cpfin_type":"1","cpfin_acrrev":75678,"cpfin_totcurrent_assets":765657656,"cpfin_curr_liabilities":0,"cpfin_totliabilities":0,"cpfin_dep":0,"cpfin_intpaid":0,"cpfin_createdby":null,"cpfin_createdon":null,"cpfin_updatedby":null,"cpfin_updatedon":null,"cpfin_intg_assets":32432,"cpfin_tot_networth":0,"cpfin_netprof_beftax":0,"cpfin_netsales":0,"cpfin_ord":1},{"cpfinid":974,"cpfincpdtid":18315,"cpfinliid":1,"cpfin_yr":"2","cpfin_type":"4","cpfin_acrrev":111,"cpfin_totcurrent_assets":12121,"cpfin_curr_liabilities":7676,"cpfin_totliabilities":76676,"cpfin_dep":43543,"cpfin_intpaid":4343,"cpfin_createdby":null,"cpfin_createdon":null,"cpfin_updatedby":null,"cpfin_updatedon":null,"cpfin_intg_assets":121232,"cpfin_tot_networth":6576765,"cpfin_netprof_beftax":5656,"cpfin_netsales":543523,"cpfin_ord":2},{"cpfinid":975,"cpfincpdtid":18315,"cpfinliid":1,"cpfin_yr":"3","cpfin_type":"4","cpfin_acrrev":7876,"cpfin_totcurrent_assets":7565677,"cpfin_curr_liabilities":5456,"cpfin_totliabilities":5676,"cpfin_dep":435,"cpfin_intpaid":5435576,"cpfin_createdby":null,"cpfin_createdon":null,"cpfin_updatedby":null,"cpfin_updatedon":null,"cpfin_intg_assets":8909854,"cpfin_tot_networth":231,"cpfin_netprof_beftax":65756754,"cpfin_netsales":45,"cpfin_ord":3}],"LoanInfo":[{"li_id":null,"li_amt":2000000,"li_createdon":null,"li_createdby":null,"li_updatedon":null,"li_updatedby":null,"li_cp_version_id":null,"li_pg_id":0,"corpDetails":null}]}


My html :

<td class="amtformatdis text-right" *ngFor="let model of list;let i = index" name="selection">
<input type="text" name="cpfin_intg_assets{{i}}" [(ngModel)]="model.cpfin_intg_assets"/>
</td>

Answer Source

As the error says ngFor doesn't work on objects, i think you need to access the CorpFinancial which is an array ,

<td class="amtformatdis text-right"  *ngFor="let model of list.CorpFinancial;let i = index" name="selection">
 <input type="text" name="cpfin_intg_assets{{i}}" [(ngModel)]="model.cpfin_intg_assets"/>  
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download