Harry
Harry

Reputation: 133

How to display array data in angular

I am new to angular. I have array data. I want to display data on my webpage.

my question is how to print data. the data showing in console.log().

My console.log screenshot

enter image description here

Upvotes: 3

Views: 95

Answers (3)

Amirkhan
Amirkhan

Reputation: 36

<div *ngFor='let measurement of ObjectName.measurements'>
    {{ measurement?.label }}
</div>

For more info please visit the angular tutorial

https://angular.io/tutorial/toh-pt2

Upvotes: 1

Sajeetharan
Sajeetharan

Reputation: 222572

In order to display array on your template you need ngFor

<ul>
    <li *ngFor="let measurement of data.measurements">
      {{ measurement }}
    </li>
</ul>

Upvotes: 1

Pardeep Jain
Pardeep Jain

Reputation: 86730

You can iterate over the array in a webpage using *ngFor directive of Angular for example -

<div *ngFor='let item of arrayName'>
  {{item?.propertyName}}
</div>

Working Example

Upvotes: 1

Related Questions