firebase
-
-
Save denismaster/46d81e6059927cf56c70f3e2b8c772e2 to your computer and use it in GitHub Desktop.
Shareable shopping cart using Angular and Firebase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NgModule } from '@angular/core'; | |
import { Routes, RouterModule } from '@angular/router'; | |
import { HomeComponent } from './home/home.component'; | |
const routes: Routes = [ { path: '', component: HomeComponent, pathMatch: 'full' },]; | |
@NgModule({ | |
imports: [RouterModule.forRoot(routes, {onSameUrlNavigation:'reload' })], | |
exports: [RouterModule] | |
}) | |
export class AppRoutingModule { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
import { ProductCategory } from '../models'; | |
import { Observable } from 'rxjs'; | |
import { take } from 'rxjs/operators' | |
import { MenuService } from '../menu/menu.service'; | |
@Component({ | |
selector: 'app-home', | |
templateUrl: './home.component.html', | |
}) | |
export class HomeComponent implements OnInit { | |
menu$: Observable<ProductCategory[]>; | |
constructor(private menuService: MenuService) { | |
} | |
ngOnInit() { | |
this.menu$ = this.menuService.getMenu().pipe(take(1)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface Product { | |
name: string; | |
weight?: number | string; | |
price?: number; | |
additionalInformation?: string; | |
} | |
export interface ProductCategory { | |
name: string; | |
products: Product[] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment