Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(router-service): add back/forward api for router. resolves #19 #78

Merged
merged 1 commit into from
Dec 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/responsive-app/src/app/app.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
margin: 0 auto;
}

.navigation-container {
display: grid;
grid-template-columns: min-content 1fr min-content;
margin-bottom: 20px;
}

main {
padding: 20px;
}
Expand Down
5 changes: 5 additions & 0 deletions apps/responsive-app/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
</mat-toolbar>

<main>
<div class="navigation-container">
<button mat-flat-button (click)="router.back()">Go Back</button>
<div></div>
<button mat-flat-button (click)="router.forward()">Go Forward</button>
</div>
<mat-grid-list cols="2" *media="'(min-width: 768px)'">
<mat-grid-tile>
<mat-nav-list>
Expand Down
2 changes: 2 additions & 0 deletions apps/responsive-app/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component } from '@angular/core';
import { Router } from 'angular-routing';

@Component({
selector: 'ra-root',
Expand All @@ -7,4 +8,5 @@ import { Component } from '@angular/core';
})
export class AppComponent {
title = 'responsive-app';
constructor(public readonly router: Router) {}
}
10 changes: 10 additions & 0 deletions libs/angular-routing/src/lib/router.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ export class Router {
this.nextState(this.getLocation());
}

forward() {
this.location.forward();
this.nextState(this.getLocation());
}

back() {
this.location.back();
this.nextState(this.getLocation());
}

go(url: string, queryParams?: Params, hash?: string) {
this.location.go(this.serializeUrl(url, queryParams, hash));

Expand Down