I'm implementing Master / Detail pattern as described in Angular2 tutorial: https://angular.io/docs/ts/latest/tutorial/toh-pt2.html
Simplified example:
import { Component } from '@angular/core';
export class Hero {
id: number;
name: string;
}
@Component({
selector: 'my-app',
template:`
<ul>
<li *ngFor="let hero of heroes" (click)="onSelect(hero)">
{{hero.name}}
</li>
</ul>
<div *ngIf="selectedHero">
<h2>{{selectedHero.name}} details!</h2>
</div>
`,
})
export class AppComponent {
heroes = HEROES;
selectedHero: Hero;
onSelect(hero: Hero) { this.selectedHero = hero; }
}
Whenever an item in a list is clicked its details are shown on the screen. However, I can't find a way to update url in the location bar to reflect the fact that one of the items is selected.
The only way seem to be to navigate to another view using router but it refreshes the whole master-detail component including the list of items.
My goal is only to refresh part of the page while keeping the url in sync with the shown content.