mp-common
Version:
This is XPO MarketPlace common libary
38 lines (31 loc) • 1.23 kB
text/typescript
import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';
import { OptionFilter } from '../../core';
({
selector: 'app-option-filter',
templateUrl: './option-filter.component.html',
styleUrls: [ './option-filter.component.scss' ]
})
export class OptionFilterComponent implements OnInit {
() private options: string[];
() private title: string;
() filter: OptionFilter;
() filterChange = new EventEmitter();
constructor() {
this.options = [];
}
ngOnInit() { }
onChangeOptionFilter($event: any, option: string) {
let selectedOption = this.filter.selectedOption ? this.filter.selectedOption : [];
if ($event.checked) {
if (selectedOption.indexOf(option.toLowerCase()) === -1) {
selectedOption.push(option.toLowerCase());
}
} else {
if (selectedOption.indexOf(option.toLowerCase()) !== -1) {
selectedOption.splice(selectedOption.indexOf(option.toLowerCase()), 1);
}
}
this.filter.selectedOption = selectedOption;
this.filterChange.emit(this.filter);
}
}