ฉันมีส่วนประกอบง่ายๆที่เรียก REST api ทุกๆสองสามวินาทีและรับข้อมูล JSON กลับมา ฉันเห็นจากคำสั่งบันทึกของฉันและปริมาณการใช้งานเครือข่ายว่าข้อมูล JSON ที่ส่งคืนกำลังเปลี่ยนแปลงและโมเดลของฉันกำลังได้รับการอัปเดตอย่างไรก็ตามมุมมองจะไม่เปลี่ยนแปลง
ส่วนประกอบของฉันดูเหมือนว่า:
import {Component, OnInit} from 'angular2/core';
import {RecentDetectionService} from '../services/recentdetection.service';
import {RecentDetection} from '../model/recentdetection';
import {Observable} from 'rxjs/Rx';
@Component({
    selector: 'recent-detections',
    templateUrl: '/app/components/recentdetection.template.html',
    providers: [RecentDetectionService]
})
export class RecentDetectionComponent implements OnInit {
    recentDetections: Array<RecentDetection>;
    constructor(private recentDetectionService: RecentDetectionService) {
        this.recentDetections = new Array<RecentDetection>();
    }
    getRecentDetections(): void {
        this.recentDetectionService.getJsonFromApi()
            .subscribe(recent => { this.recentDetections = recent;
             console.log(this.recentDetections[0].macAddress) });
    }
    ngOnInit() {
        this.getRecentDetections();
        let timer = Observable.timer(2000, 5000);
        timer.subscribe(() => this.getRecentDetections());
    }
}และมุมมองของฉันดูเหมือนว่า:
<div class="panel panel-default">
    <!-- Default panel contents -->
    <div class="panel-heading"><h3>Recently detected</h3></div>
    <div class="panel-body">
        <p>Recently detected devices</p>
    </div>
    <!-- Table -->
    <table class="table" style="table-layout: fixed;  word-wrap: break-word;">
        <thead>
            <tr>
                <th>Id</th>
                <th>Vendor</th>
                <th>Time</th>
                <th>Mac</th>
            </tr>
        </thead>
        <tbody  >
            <tr *ngFor="#detected of recentDetections">
                <td>{{detected.broadcastId}}</td>
                <td>{{detected.vendor}}</td>
                <td>{{detected.timeStamp | date:'yyyy-MM-dd HH:mm:ss'}}</td>
                <td>{{detected.macAddress}}</td>
            </tr>
        </tbody>
    </table>
</div>ฉันสามารถเห็นได้จากผลลัพธ์ของconsole.log(this.recentDetections[0].macAddress)อ็อบเจ็กต์ latestDetections ที่กำลังอัปเดต แต่ตารางในมุมมองไม่เคยเปลี่ยนแปลงเว้นแต่ฉันจะโหลดเพจซ้ำ
ฉันกำลังดิ้นรนเพื่อดูว่าฉันทำอะไรผิดที่นี่ ใครสามารถช่วย?