You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

28 lines
794 B

  1. import { Component, OnInit } from '@angular/core';
  2. import { Router, ActivatedRoute } from '@angular/router';
  3. import { Store } from '@ngrx/store';
  4. import { Observable } from 'rxjs/Observable';
  5. import * as fromRecipe from '../ngrx/recipe.reducers';
  6. @Component({
  7. selector: 'app-recipe-list',
  8. templateUrl: './recipe-list.component.html',
  9. styleUrls: ['./recipe-list.component.css']
  10. })
  11. export class RecipeListComponent implements OnInit {
  12. recipeState: Observable<fromRecipe.State>;
  13. constructor(private router: Router,
  14. private route: ActivatedRoute,
  15. private store: Store<fromRecipe.FeatureState>) { }
  16. ngOnInit() {
  17. this.recipeState = this.store.select('recipes');
  18. }
  19. onNewRecipe() {
  20. this.router.navigate(['new'], {relativeTo: this.route});
  21. }
  22. }