Skip to content

Instantly share code, notes, and snippets.

@Dornhoth
Created June 1, 2020 17:32
Show Gist options
  • Save Dornhoth/1b58a69a0b0c5f12263eb4cbdc6a65e3 to your computer and use it in GitHub Desktop.
Save Dornhoth/1b58a69a0b0c5f12263eb4cbdc6a65e3 to your computer and use it in GitHub Desktop.
<app-multiselect name="my-component" [items]="possiblePets" (itemSelected)="addPet($event)"></app-multiselect>
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
name = '';
pets = [];
hasPets = false;
possiblePets = [{ id: '1', text: 'Cat' }, { id: '2', text: 'Dog' },
{ id: '3', text: 'Parrot' }, { id: '4', text: 'Rabbit' },
{ id: '5', text: 'Turtle' }, { id: '6', text: 'Hamster' },
{ id: '7', text: 'Duck' }, { id: '8', text: 'Goose' }];
addPet(pet): void {
this.pets.push(pet);
console.log(this.pets);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment