i have a method function that create object. here my function
packetdata:any[];
ngOnInit() {
this.service.getonepacket(this.nopacket).subscribe(
data => {
return this.packetdata = data;
},
error => console.log(this.errorMessage = <any>error)
)
}
if i use console log this.packet it result object like this
Object {idpacket: 3, packetname: "Packet C", packetdesc: "SMS 20 sms/hari, Storage 20Gb", packetprize: "Rp. 300.000/bulan", packettime: 30}
i try to put that each value on my table like this
<h3 class="page-header">Your Bill Information</h3>
<table class="table table-striped">
<tr>
<th *ngFor="let item of packetdata"> Packet Name </th>
<td>{{item.packetname}}</td>
</tr>
<tr>
<th *ngFor="let item of packetdata"> Description </th>
<td> {{item.packetdesc}} </td>
</tr>
<tr>
<th *ngFor="let item of packetdata"> Prize </th>
<td> {{item.packetprize}} </td>
</tr>
<tr>
<th *ngFor="let item of packetdata"> Minimal Contract time (day) </th>
<td> {{item.packettime}} </td>
</tr>
</table>
but it return error Error Cannot read property.
How to resolve this?.