import { Component , OnInit } from '@angular/core' ; import { Router } from '@angular/router' ; import { Observable } from 'rxjs/Observable' ; import { Category , CategoryService } from './category.service' ; @ Component ( { selector : 'db-category-list' , templateUrl : 'app/category/category-list.component.html' } ) export class CategoryListComponent implements OnInit { categories : Observable < Category [ ] > ; constructor ( private router , private categoryService ) { } ngOnInit ( ) { this . categories = this . categoryService . getCategories ( ) ; } filterProducts ( category ) { this . router . navigate ( [ '/products' ] , { queryParams : { category : category . id } } ) ; } }