Search code examples
angulartypescriptangular4-forms

Angular 4. Binding dynamic array elements


In my ts file i have declared an array like

userData = [];

By an API i fill this array by whatever data i get.

this.userData = data['franchise'];

In my HTML file i am showing the data like this.

<div class="text-div">{{userData.fm_name != undefined ? userData.fm_name : ''}}</div>

All this is working fine in local but on production i am getting an error like

Property 'name' does not exist on type 'any[]'.

Please Help me here. Thank you in advance.


Solution

  • I didn't got what you said but i think declaring your element like this

    userData:any={};
    

    should work.

    And if you want to loop over an array then declare an array

    loopArray = [];
    this.loopArray = this.userdata['loopData'];