Skip to content

Instantly share code, notes, and snippets.

@SteffenJahr
Last active February 28, 2020 11:47
Show Gist options
  • Select an option

  • Save SteffenJahr/8d39699121f259569717a7e465dfd51c to your computer and use it in GitHub Desktop.

Select an option

Save SteffenJahr/8d39699121f259569717a7e465dfd51c to your computer and use it in GitHub Desktop.
PWA-Workshop Lab #6
  1. Remove all code from app.component.html except <router-outlet></router-outlet> and wrap it into <app-nav>.
  2. Add an input and a button to add new todos in the app component template app.component.html.
  3. Add an add method to app.component.ts
  4. Add <ng-content></ng-content> at the placeholder location in nav.component.html.
  5. Run ng build --prod.
  6. In a new terminal window switch to the my-pwa/dist/my-pwa/ folder and execute npx lite-server. A browser window with your application should now open with url http://localhost:3000
<app-nav>
<input type="text" #input /><button (click)="add(input.value)">Hinzufügen</button>
<router-outlet></router-outlet>
</app-nav>
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
})
export class AppComponent {
title = 'my-pwa';
add(value: string) {
console.log(value);
}
}
<mat-sidenav-container class="sidenav-container">
<mat-sidenav #drawer class="sidenav" fixedInViewport
[attr.role]="(isHandset$ | async) ? 'dialog' : 'navigation'"
[mode]="(isHandset$ | async) ? 'over' : 'side'"
[opened]="(isHandset$ | async) === false">
<mat-toolbar>Menu</mat-toolbar>
<mat-nav-list>
<a mat-list-item href="#">Link 1</a>
<a mat-list-item href="#">Link 2</a>
<a mat-list-item href="#">Link 3</a>
</mat-nav-list>
</mat-sidenav>
<mat-sidenav-content>
<mat-toolbar color="primary">
<button
type="button"
aria-label="Toggle sidenav"
mat-icon-button
(click)="drawer.toggle()"
*ngIf="isHandset$ | async">
<mat-icon aria-label="Side nav toggle icon">menu</mat-icon>
</button>
<span>my-pwa</span>
</mat-toolbar>
<!-- Add Content Here -->
<ng-content></ng-content>
</mat-sidenav-content>
</mat-sidenav-container>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment