import { Component } from '@angular/core' ; import { Facet , FacetDeselect , FacetDeselectAll , FacetEvent , FacetSelect } from '@ux-aspects/ux-aspects' ; import 'chance' ; @ Component ( { selector : 'app' , templateUrl : './app.component.html' } ) export class AppComponent { facets : Facet [ ] = [ ] ; event : string ; constructor ( ) { for ( let idx = 0 ; idx < 30 ; idx ++ ) { this . facets . push ( new Facet ( chance . name ( ) , null , chance . integer ( { min : 0 , max : 100 } ) ) ) ; } this . facets . sort ( ( facetOne , facetTwo ) => { if ( facetOne . title < facetTwo . title ) { return - 1 ; } if ( facetOne . title > facetTwo . title ) { return 1 ; } return 0 ; } ) ; } onEvent ( event ) { if ( event instanceof FacetSelect ) { this . event = `${ event . facet . title } was selected!` ; } if ( event instanceof FacetDeselect ) { this . event = `${ event . facet . title } was deselected!` ; } if ( event instanceof FacetDeselectAll ) { this . event = 'All facets were deselected!' ; } } }