Reputation: 167
Here is my function that takes resLS as an object array. I am trying to display arr in html element using Angular 4. But when I do {{arr}}, I don't see anything in html. I was expecting to see some element appended in arr array and I definitely see data in console. What am I missing?
findLastValueLS(resLS, name: String) {
let index = resLS.NewDataSet.Table.findIndex(d => d.DataPointName[d.DataPointName.findIndex(DataPointName => DataPointName === name)]);
console.log(resLS.NewDataSet.Table[index].LastValue);
var arr = [];
arr.push(resLS.NewDataSet.Table[index].LastValue);
}
Upvotes: 1
Views: 15266
Reputation: 3332
Use ngFor :
<div *ngFor="let item of arr">
Name : {{ item }}
</div>
Upvotes: 4
Reputation: 131
Use *ngFor if you are using Angular, or ng-repeat if you are using AngularJS. See the documentation:
AngularJS : https://docs.angularjs.org/api/ng/directive/ngRepeat Angular:https://angular.io/api/common/NgForOf
Sample for Angular:
<div *ngFor='item of arr'> {{item}} </div>
Upvotes: 0