servers.component.html
<div class="row"> <div class="col-xs-12 col-sm-4"> <div class="list-group"> <a href="#" class="list-group-item" *ngFor="let server of servers"> {{ server.name }} </a> </div> </div> <div class="col-xs-12 col-sm-4"> <button class="btn btn-primary" (click)="onReload()">Reload Page</button> <app-edit-server></app-edit-server> <hr> <app-server></app-server> </div> </div>
servers.component.ts
import {Component, OnInit} from '@angular/core'; import {ServersService} from './servers.service'; import {ActivatedRoute, Router} from '@angular/router'; @Component({ selector: 'app-servers', templateUrl: './servers.component.html', styleUrls: ['./servers.component.css'] }) export class ServersComponent implements OnInit { private servers: { id: number, name: string, status: string }[] = []; constructor(private serversService: ServersService, private router: Router, private route: ActivatedRoute) { } ngOnInit() { this.servers = this.serversService.getServers(); } onReload() { this.router.navigate(['servers'], {relativeTo: this.route}); } }