### File

`modules/category-filter-component/src/category-filter.component.ts`

### Description

Has a select input with categories that user inject. Emit new category id when category updated

### Metadata

selector | `app-category-filter`
styleUrls | `category-filter.component.scss`
templateUrl | `category-filter.component.html`

### Inputs

`categories` | Store categories

### Outputs

`categoryUpdated` | `$event` type: `EventEmitter`

### Constructor

`constructor()`

### Methods

updated
`updated(newCategoryId: any)`

Emit new category id when user update a category in select box

Parameters :

- newCategoryId

  store category id

Returns: `void`

    import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';

    /**
     * Has a select input with categories that user inject. Emit new category id when category updated
     */
    @Component({
      selector: 'app-category-filter',
      templateUrl: './category-filter.component.html',
      styleUrls: ['./category-filter.component.scss']
    })
    export class CategoryFilterComponent implements OnInit {

      /**
       * Store categories
       */
      @Input() categories = [];

      @Output() categoryUpdated = new EventEmitter();

      constructor() { }

      ngOnInit() {
        console.log(this.categories);
      }

      /**
       * Emit new category id when user update a category in select box
       * @param newCategoryId store category id
       */
      updated(newCategoryId){
        this.categoryUpdated.emit(newCategoryId);
      }

    }

# results matching ""

# No results matching ""