1 import { Component, OnChanges } from '@angular/core';
2 import { Input } from '@angular/core';
5 selector: 'cd-select-badges',
6 templateUrl: './select-badges.component.html',
7 styleUrls: ['./select-badges.component.scss']
9 export class SelectBadgesComponent implements OnChanges {
11 data: Array<string> = [];
13 options: Array<SelectBadgesOption> = [];
15 emptyMessage = 'There are no items.';
20 if (!this.options || !this.data || this.data.length === 0) {
23 this.options.forEach((option) => {
24 if (this.data.indexOf(option.name) !== -1) {
25 option.selected = true;
30 private updateOptions() {
31 this.data.splice(0, this.data.length);
32 this.options.forEach((option: SelectBadgesOption) => {
33 if (option.selected) {
34 this.data.push(option.name);
39 selectOption(option: SelectBadgesOption) {
40 option.selected = !option.selected;
44 removeItem(item: string) {
45 const optionToRemove = this.options.find((option: SelectBadgesOption) => {
46 return option.name === item;
48 optionToRemove.selected = false;