The following is something I'm trying to get working based on the Angular Tutorial.
export class DashboardComponent implements OnInit {
title = 'Current Robots';
private sobots: Robot[];
constructor(
private router: Router,
private sobotService: RobotService) {
}
getRobots() {
this.sobotService.getRobots().then(sobots => Array.prototype.push.apply(this.sobots, sobots.data));
}
ngOnInit() {
this.getRobots();
}
gotoDetail(sobot: Robot) {
let link = ['/detail', sobot.Id];
this.router.navigate(link);
}
And the View
<h3>{{title}}</h3>
<div class="grid grid-pad">
<div *ngFor="let sobot of sobots" (click)="gotoDetail(sobot)" class="col-1-4">
<div class="module sobot">
<p>HostKey</p>
<h4>{{sobot.HostKey}}</h4>
</div>
</div>
</div>
<sobot-search></sobot-search>
sobots.data looks to be returning the data object as expected - however it's still not updating until I click on any button/route/any event is fired.
No errors show up in the console and I'm quite confused!
I've gone ahead and tried to ensure that it's only adding data to the original array object but even that doesn't seem to work!